I'm using react-navigation and have a StackNavigator with a ParentScreen and a ChildScreen.
Both screens have the same navigation bar with a dynamic value from redux. Implemented like described in Issue #313
This works as expected. When I'm in DetailScreen and I update the value for the count variable, it also updates the value in the navigation bar.
Problem is, if I go back to the parent scene, there is still the old value in the navigation bar. It doesn't update to the current value in redux store.
Child
Parent (when I go back)
ChildScreen
class ChildScreen extends Component {
static navigationOptions = {
title: ({ state }) => `Total: ${state.params && state.params.count ? state.params.count : ''}`
};
componentWillReceiveProps(nextProps) {
if (nextProps.count != this.props.count) {
this.props.navigation.setParams({ count: nextProps.count });
}
}
render() {
return (
<View>
<Button onPress={() => this.props.increment()} title="Increment" />
</View>
);
}
}
ParentScreen
class ParentScreen extends Component {
static navigationOptions = {
title: ({ state }) => `Total: ${state.params && state.params.count ? state.params.count : ''}`
};
}
Any advice?