react-navigation-addons
react-navigation-addons copied to clipboard
Infinite loop
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
Encountering exactly the same issue with RN 0.43.3 and React 16.0.0-alpha.6
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
})
}
}
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.