react-navigation / react-navigation.github.io

Home of the documentation and other miscellanea
https://reactnavigation.org/
MIT License
312 stars 1.89k forks source link

Documentation for blocking navigation actions like back #368

Open brentvatne opened 5 years ago

brentvatne commented 5 years ago

https://reactnavigation.org/docs/en/routers.html#blocking-navigation-actions - this is pretty barebones. One use case that came up was to fire a query when the user presses back and only complete that when the query is complete and the result matches some criteria. These docs don't say how to handle async

jarvisluong commented 5 years ago

Do you have any suggestions in mind to handle async? I looked at the source code of getStateForAction and it is not async itself so how do we get the router to wait until the async operation is completed?

vdlindenmark commented 5 years ago

For the back case: what I do is returning nothing and let my function handle the goBack action itself.