Blocking navigation (onBeforeNavigate?) #593
-
I'd like to be able to block a user leaving a scene if there are unsaved changes. There is no mention of how to do this sort of thing in the docs that I can see, and from digging through the code I can see the onBeforeNavigate prop available when setting up states. But this seems like it's supposed to be set up when the app is initialised, whereas I'd like to be able to define the function that gets called from within the scene itself because that is where I will know what to do depending on the state of the scene. Is there a preferred way of doing this? I tried doing
But it causes strange glitchy behaviour where the scene is left but then it jumps back to it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 15 replies
-
Yea, |
Beta Was this translation helpful? Give feedback.
Yea,
onBeforeNavigate
blocks navigation but only if it happens in React first. It can't block navigations that happen on the native side first. So I'm guessing the 'glitchy behaviour' you're seeing is on iOS when you swipe/press back?