-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[changed] Remove preserveScrollPosition, add scrollStrategy
This removes support for `preserveScrollPosition` due to its unforunate naming. Instead, we introduce three scrolling strategies: * `none`: Router doesn't scroll the window when routes change * `scrollToTop` (default): Router always scrolls to top when routes change * `imitateBrowser`: Router tries to act like browser acts with server-rendered pages: it scrolls to top when clicking on links, but tries to restore position when navigating back and forward You can only specify these on <Routes />. Per-route overrides are not supported, but you can supply a custom strategy object. This also fixes #252. Migration path: The default changed from what corresponded to `imitateBrowser`, to `scrollToTop`. If router's server-rendered scrolling imitation worked well for you, you must now specify it explicitly: ``` // before <Routes> <Routes preserveScrollPosition={false}> // after <Routes scrollStrategy='imitateBrowser'> ``` If you wish router to not try to manage scrolling, you must opt out: ``` // before <Routes preserveScrollPosition={true}> // after <Routes scrollStrategy='none'> ``` Also, as a third option, you may now use the simple `scrollToTop` strategy.
- Loading branch information
Showing
14 changed files
with
315 additions
and
136 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
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,10 @@ | ||
var keyMirror = require('react/lib/keyMirror'); | ||
|
||
var ActionTypes = keyMirror({ | ||
SETUP: null, | ||
PUSH: null, | ||
REPLACE: null, | ||
POP: null | ||
}); | ||
|
||
module.exports = ActionTypes; |
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
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
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
Oops, something went wrong.