@@ -11,11 +11,17 @@ function routeParamsChanged(route, prevState, nextState) {
11
11
} )
12
12
}
13
13
14
+ function routeQueryChanged ( prevState , nextState ) {
15
+ return prevState . location . search !== nextState . location . search
16
+ }
17
+
14
18
/**
15
19
* Returns an object of { leaveRoutes, enterRoutes } determined by
16
20
* the change from prevState to nextState. We leave routes if either
17
21
* 1) they are not in the next state or 2) they are in the next state
18
- * but their params have changed (i.e. /users/123 => /users/456).
22
+ * but their params have changed (i.e. /users/123 => /users/456) or
23
+ * 3) they are in the next state but the query has changed
24
+ * (i.e. /search?query=foo => /search?query=bar)
19
25
*
20
26
* leaveRoutes are ordered starting at the leaf route of the tree
21
27
* we're leaving up to the common parent route. enterRoutes are ordered
@@ -28,7 +34,9 @@ function computeChangedRoutes(prevState, nextState) {
28
34
let leaveRoutes , enterRoutes
29
35
if ( prevRoutes ) {
30
36
leaveRoutes = prevRoutes . filter ( function ( route ) {
31
- return nextRoutes . indexOf ( route ) === - 1 || routeParamsChanged ( route , prevState , nextState )
37
+ return nextRoutes . indexOf ( route ) === - 1
38
+ || routeParamsChanged ( route , prevState , nextState )
39
+ || routeQueryChanged ( prevState , nextState )
32
40
} )
33
41
34
42
// onLeave hooks start at the leaf route.
0 commit comments