Component gets blur event on launch if custom navigation params was set up.
punksta opened this issue · 0 comments
punksta commented
you compare whole state here in _handleNavigationStateChange
function
const focused = state.routes[state.index] === this.props.navigation.state;
but if we use custom navigation params, these objects can be different.
so it's better to compare key
.
const focused = state.routes[state.index].key === this.props.navigation.state.key;
let's say we have component that sets custom params and receives screenArg
from parent screen via navigation action :
this.props.navigation.setParams({ customX: this._foo, customY: this.props.bar });
here is my console eval output when first visit of the component.
_this.props.navigation.state === state.routes[state.index]
false
_this.props.navigation.state.key === state.routes[state.index].key
true
state.routes[state.index].params
Object {screenArg: Object, customX: function, customY: function}
_this.props.navigation.state.params
Object {screenArg: Object}
Keys are equals, but whole states are different and screen will have "blur" event on launch.