Like in the web browser, we have onBeforeUnload (vs onUnload) to show a alert or some warning "there is unsaved data - are you sure you want to go back".

I am trying to do the same. I couldn't find anything in the docs of react-navigation.

I thought of doing something real hacky like this, but I don't know if its the right way: