In react native after componentDidMount()
its not call again when you navigate to other screens and return to your component (screen). so react native navigation suggest do it by bellow JS codes:
componentDidMount() {
this._Reload = this.props.navigation.addListener('focus', () => {
//do something to reset component
});
}
componentWillUnmount() {
this._Reload();
}
but now I get this error: undefined is not an object (evaluating 'this.props.navigation.addListener')
because I use my component in a tab component(nested). how can I add a focus to my component to refresh?
I think I must do it by prop drilling.