Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Infinite loop #10

Open
logileifs opened this issue May 17, 2017 · 3 comments
Open

Infinite loop #10

logileifs opened this issue May 17, 2017 · 3 comments

Comments

@logileifs
Copy link

I am using StackNavigator and tried to use navigation addons to know when component is rendering on goBack() but when I wrap my StackNavigator with the enhance method my component gets stuck in componentWillMount loop. componentWillMount just gets called over and over again and nothing happens. Android 6.0.1 and RN 0.44

@GuillaumeMunsch
Copy link

Encountering exactly the same issue with RN 0.43.3 and React 16.0.0-alpha.6

@tmaly1980
Copy link

tmaly1980 commented Jun 27, 2017

Is it componentWillReceiveProps that is stuck in a loop? My guess is because you're updating this.props.navigation in the process, it triggers componentWillReceiveProps again. Probably should do a check inside componentWillReceiveProps to look for a specific property being different than before (ie NOT nextProps.navigation) to then do the update. In my case, this worked:

  componentWillMount () {
    this.props.navigation.setOptions({
      headerTitle: this.props.business.name
    })
  }

  componentWillReceiveProps (nextProps) {
    if (nextProps.business && (!this.props.business || nextProps.business.name !== this.props.business.name)) {
      this.props.navigation.setOptions({
        headerTitle: nextProps.business.name
      })
    }
  }

@kiwipxl
Copy link

kiwipxl commented Sep 14, 2017

I'm getting this issue literally any time an error occurs in my emulator. I don't even have to be using any of the addon features - if I wrap enhance around the AppNavigator then this will always happen.
I'm using React Native 0.48.3 (although this issue was happening < 0.40), so this definitely seems like a react-navigation-addons error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants