Screen1: - loads content from an api over network. - User presses a button to add new item to the list - Screen 2 opens (Navigator.push)
After completing the action on screen 2 (uploading the new item to the list), when user moves back to the screen 1, the object doesn't get updated. I have tried passing an updateobject() method as a prop to the screen 2 but still it doesn't seem to work.
Would really appreciate if someone can help me know if there is a componentlifecycle method that is triggered when navigator goes back to the screen1
Just an idea but might be worth checking out something like redux to manage your state.
It really is excellent and it'll allow you to update state centrally (with a reducer) based on things happening in the background or foreground via actions (API requests probably need async actions so check redux-thunk for how).
You then use react-redux to connect parts of this centralised state to your components.
This will mean that you do not need a component lifecycle method as state changes centrally, props will be passed to components and as we all know with react they re-render accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With