react-navigation-addons icon indicating copy to clipboard operation
react-navigation-addons copied to clipboard

Infinite loop

Open logileifs opened this issue 7 years ago • 3 comments

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

logileifs avatar May 17 '17 17:05 logileifs

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

GuillaumeMunsch avatar May 24 '17 12:05 GuillaumeMunsch

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
      })
    }
  }

tmaly1980 avatar Jun 27 '17 16:06 tmaly1980

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.

kiwipxl avatar Sep 14 '17 09:09 kiwipxl