Closed tsvetann closed 1 year ago
What action does the drawer items fire in order to navigate away? Could you use the state of the form to prevent that action from affecting the navigation state in your reducer?
mostly reset/push routes (if that is your question). I somehow feel uncomfortable complicating my simple form by exposing it global state just to achieve that. I wish there was something similar to NavigationPrompt from https://react-router-website-xvufzcovng.now.sh/preventing-transitions
I would be concerned about putting something like blockTransitions
in my app, because random components in your app will have the ability to block navigation for everyone, which may be hard to debug.
Passing navigation state down as explicit props for a clear reason is not global state, as you suggest. If you want the props to be more specific, you can always do that.
I would also advise putting this logic in your reducers instead of your component tree.
What I would like to achieve is the following:
I have Scene A which contains a form. There is also Drawer with options to change the Scene. I would like somehow catch when the user wants to navigate away from Scene A and actually stop navigation and show a Modal asking are you sure you would like to discard the form (or something similar). My question is whats the best way to detect and pause the transition between scenes?
[Navigation state is handled in redux]
Thanks in advance for any advices