Skip to content

Commit

Permalink
fixed incorrect leave behavior
Browse files Browse the repository at this point in the history
test is in parent commit
  • Loading branch information
ryanflorence committed Mar 10, 2016
1 parent 96ed936 commit d5747e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## [HEAD]
> Unreleased
- Nothing yet!
- Fixed bug where transition hooks were not called on child routes of
parent's whose params changed but the child's did not. ([#3166])

[#3166][https://github.com/reactjs/react-router/pull/3166]

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

Expand Down
10 changes: 9 additions & 1 deletion modules/computeChangedRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ function computeChangedRoutes(prevState, nextState) {

let leaveRoutes, enterRoutes
if (prevRoutes) {
let parentIsLeaving = false
leaveRoutes = prevRoutes.filter(function (route) {
return nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState)
if (parentIsLeaving) {
return true
} else {
const isLeaving = nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState)
if (isLeaving)
parentIsLeaving = true
return isLeaving
}
})

// onLeave hooks start at the leaf route.
Expand Down

0 comments on commit d5747e9

Please sign in to comment.