Skip to content
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

Support for react router v6 #81

Open
jmdsg opened this issue Dec 19, 2021 · 11 comments
Open

Support for react router v6 #81

jmdsg opened this issue Dec 19, 2021 · 11 comments

Comments

@jmdsg
Copy link

jmdsg commented Dec 19, 2021

I would like to know if there is a plan to support react router v6.
I checked the source code of this project, and also the migration guide from v5 to v6, and think the only changes needed would be:

  1. Stop using the HOC withRouter since is not avaibale anymore.
  2. Obtain the location using the useLocation hook or receive it as a parameter
  3. Obtain the history. This one is trickier since is aparently not exposed anymore by react-router. Maybe it should be passed as a parameter, and it would be the user's resposability get it.

React router seems to be working on usePrompt and useBlocker, but those are not yet done. Meanwhile people that updates to v6, will not be able to use those nor this package.

@ZacharyRSmith
Copy link
Owner

@jmdsg thanks for opening this issue! If you or someone else wants to open a PR for v6, I'll merge! However, I do not plan to dev it myself.

@shamilykr
Copy link

@jmdsg @ZacharyRSmith Is there any update for this issue ?

@ZacharyRSmith
Copy link
Owner

@shamilykr no. If you can, please open a PR. Thanks!

@sshyam-gupta
Copy link

Try this package if it helps
https://www.npmjs.com/package/react-router-prompt

@notShadowM
Copy link

Try this package if it helps https://www.npmjs.com/package/react-router-prompt

yoo it was really helpful.
Good job man.

@notShadowM
Copy link

Try this package if it helps https://www.npmjs.com/package/react-router-prompt

yoo it was really helpful. Good job man.

don't really want to be annoying but is it hard to trigger on closing the tap or reloading it😢

@ZacharyRSmith
Copy link
Owner

@notShadowM , when you wrote "it hard to trigger on closing the tap or reloading itcry", were you writing about this pkg, react-router-navigation-prompt, or react-router-prompt? If this pkg, thanks for the feedback! Would you please provide more details?

@notShadowM
Copy link

notShadowM commented Aug 18, 2022

@ZacharyRSmith
i was talking about the react-router-prompt, it's working well as needed and your custom prompt will show up, but when u do close or reload ,the default prompt for your browser will show up not the custom prompt.
In general it's viable for v6 and help a lot

@ZacharyRSmith
Copy link
Owner

ZacharyRSmith commented Aug 18, 2022

@notShadowM

when u do close or reload ,the default prompt for your browser will show up not the custom prompt.

Navigation away from your site, reload, or closing tab/window will also prompt navigation confirmation when 's props.when is truthy. However, for security concerns browsers usually handle this navigation UX themselves, leading to vanilla alert boxes. Also, many browsers require users to interact with your site before confirming navigation away.

In general it's viable for v6 and help a lot

This pkg, react-router-navigation-prompt, now works for v6? So we can close this GitHub issue?

@notShadowM
Copy link

@ZacharyRSmith
it's react-router-prompt that works well with v6.
react-router-navigation-prompt still has some problems with v6.

@ZacharyRSmith
Copy link
Owner

Thanks for the info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants