-
-
Notifications
You must be signed in to change notification settings - Fork 10.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
@remix-run/router
: Add support for navigation blocking
#9709
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
0cc6142
history: allow multiple listeners
chaance 3c8606c
bump UMD filesize limit
chaance 04a8c8f
feat(router): add support for history blocking APIs
chaance 2497c02
Merge branch 'dev' into history-blocking
chaance cbad7dc
chore: add changeset
chaance 5d98596
Tweak changeset
chaance 8e0a8d0
revert unrelated history changes
chaance 0eedecf
fix tests
chaance 8c4ef44
add missing blockers obj
chaance 82a8267
add missing functions for router
chaance 226eb08
implement useBlocker
chaance 0b24b3c
add useBlocker to example
chaance c5f0384
fix issues with POP blocking
chaance 12d8860
don't recreate existing blockers
chaance 5d04b58
add support for option
chaance 4a5ce97
usePrompt implementation
chaance 70c4e86
fix subtle bugs when navigating to the same route
chaance f2ff193
implement beforeunload handler
chaance 6823f58
patch fix for async tests
chaance 3545cdc
Merge branch 'dev' into history-blocking
chaance f56ab7d
Fix history index issue and wire up singleton blocking
brophdawg11 e34bde0
Merge branch 'dev' into history-blocking
chaance 5a81d17
fix some blocking tests
chaance 934692f
Merge branch 'dev' into history-blocking
chaance 7285473
Add beforeUnload flag to useBlocker
brophdawg11 8cfc7d3
Add navigation blocking example
brophdawg11 d2f05a1
Updates
brophdawg11 12f6daa
Remove manual back button
brophdawg11 bb1bb0a
update router blocking tests
chaance 50d7c80
add missing method in server
chaance 139974d
revert changes in data router example
chaance e6cbdbb
update hook name in logs
chaance a943da9
update tests
chaance 65bba99
add use-blocker tests
chaance 23d3aac
Merge branch 'history-blocking' of github.com:remix-run/react-router …
chaance 2859b13
Merge branch 'dev' into history-blocking
chaance ba5c76d
update tests
chaance 6fba7e5
bump umd bundle size limit
chaance f4d6b00
update blocker and shouldBlock function interface
chaance e25325e
update example
chaance 27568f7
update example and mark exports as unstable
chaance fa00b37
add changeset
chaance 546e3ac
update changeset
chaance 76e7fde
update readme
chaance 2334a5b
relax reliance on boolean type for blocker function
chaance b507993
update tests
chaance e1426d0
Revert to prior usePrompt example
brophdawg11 16e464f
Move useBlocker to react-router, remove getBlockerState
brophdawg11 b9739ba
Minor updates
brophdawg11 28da8cb
update build script
chaance b29b5e0
Bump bundle
brophdawg11 887314a
export from react-router-native
chaance 6f15186
Merge branch 'history-blocking' of github.com:remix-run/react-router …
chaance 7749172
rm prompt from example
chaance File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"react-router-dom": patch | ||
--- | ||
|
||
Added pass-through event listener options argument to `useBeforeUnload` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@remix-run/router": minor | ||
--- | ||
|
||
Added support for navigation blocking APIs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"react-router-dom": minor | ||
--- | ||
|
||
Add `unstable_useBlocker` hook for blocking navigations within the app's location origin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,5 @@ node_modules/ | |
/packages/react-router-dom-v5-compat/react-router-dom | ||
|
||
.eslintcache | ||
/.env | ||
/.env | ||
/NOTES.md | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"installDependencies": true, | ||
"startCommand": "npm run dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: Navigation Blocking | ||
toc: false | ||
order: 1 | ||
--- | ||
|
||
# Navigation Blocking | ||
|
||
This example demonstrates using `unstable_useBlocker` to prevent navigating away from a page where you might lose user-entered form data. A potentially better UX for this is storing user-entered information in `sessionStorage` and pre-populating the form on return. | ||
|
||
## Preview | ||
|
||
Open this example on [StackBlitz](https://stackblitz.com): | ||
|
||
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/navigation-blocking?file=src/App.tsx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>React Router - Navigation Blocking</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed somewhere to keep notes because this was getting confusing 😅