Skip to content

Commit d5747e9

Browse files
committed
fixed incorrect leave behavior
test is in parent commit
1 parent 96ed936 commit d5747e9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
## [HEAD]
22
> Unreleased
33
4-
- Nothing yet!
4+
- Fixed bug where transition hooks were not called on child routes of
5+
parent's whose params changed but the child's did not. ([#3166])
6+
7+
[#3166][https://github.com/reactjs/react-router/pull/3166]
58

69
[HEAD]: https://github.com/reactjs/react-router/compare/v2.0.0...HEAD
710

modules/computeChangedRoutes.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ function computeChangedRoutes(prevState, nextState) {
2727

2828
let leaveRoutes, enterRoutes
2929
if (prevRoutes) {
30+
let parentIsLeaving = false
3031
leaveRoutes = prevRoutes.filter(function (route) {
31-
return nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState)
32+
if (parentIsLeaving) {
33+
return true
34+
} else {
35+
const isLeaving = nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState)
36+
if (isLeaving)
37+
parentIsLeaving = true
38+
return isLeaving
39+
}
3240
})
3341

3442
// onLeave hooks start at the leaf route.

0 commit comments

Comments
 (0)