-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove support for warnWhenUnsavedChange when react-router doesn't allow it #8272
Conversation
Is it possible to preempt the user's own onSubmit method (or alternatively, fired subsequent to the user's one) with one created by React Admin, so that when the warning prop is in use, it's that interstitial method that triggers first, thereby calling the warning up instead of submitting the form? That would not require any use of navigator.block, but would result in a similar outcome. |
@crates I'm not sure I understand. Are you suggesting that |
No, you are totally right. That suggestion made no sense. How about a custom router component provided by React Admin? Something like what they are discussing on this thread? |
that actually still works with and custom history
|
@TrejGun - Agreed; that's what we're using on our project also, with React Router 6.4 |
@crates reimplementing a custom router is outside of the scope of react-admin. We have enough work without it ;)
@TrejGun You're right, that's why the PR description says
So we have to prevent the app from breaking in that case, and that's why this PR is necessary. |
Problem
React-router 6.4.0 removed support for
navigator.block
, which is necessary for thewarnWhenUnsavedChanges
feature (see remix-run/react-router#9262).This breaks existing applications using react-router >= 6.4 and a custom router.
Solution
The
warnWithUnsavedChanges
feature fails silently when using with react-router >= 6.4Closes #8163