This repository was archived by the owner on Oct 26, 2018. It is now read-only.
File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,15 @@ function syncReduxAndRouter(history, store) {
42
42
) ;
43
43
}
44
44
45
+ // Capture the initial path so that redux devtools knows where
46
+ // to go back after a 'RESET' action
47
+ let initialPath ;
48
+
45
49
history . listen ( location => {
50
+ if ( ! initialPath ) {
51
+ initialPath = locationToString ( location ) ;
52
+ }
53
+
46
54
// Avoid dispatching an action if the store is already up-to-date,
47
55
// even if `history` wouldn't do anthing if the location is the same
48
56
if ( store . getState ( ) . routing . path !== locationToString ( location ) ) {
@@ -52,6 +60,13 @@ function syncReduxAndRouter(history, store) {
52
60
53
61
store . subscribe ( ( ) => {
54
62
const routing = store . getState ( ) . routing ;
63
+
64
+ // Catch when devtools has 'RESET' the state and force
65
+ // navigation back to the initial location
66
+ if ( routing . path === undefined ) {
67
+ routing . path = initialPath ;
68
+ }
69
+
55
70
// Don't update the router is nothing has changed. The
56
71
// `avoidRouterUpdate` flag can be set to avoid updating altogether,
57
72
// which is useful for things like loading snapshots or very special
You can’t perform that action at this time.
0 commit comments