Monday 25 November 2019

reactjs - Access props inside a closure

calling this.props.navigation.dispatch(resetAction); inside componentWillMount() works fine for me, but if I try this code




componentWillMount(){
Keychain
.getGenericPassword()
.then(function(credentials) {
this.props.navigation.dispatch(resetAction);
})
}



I get an error telling me that this.props.navigation is undefined. I suppose that the problem is that I am calling it inside .then. Do you know how can I solve this?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...