Skip to content

Commit

Permalink
Update docs. Fill in some missed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
timdorr committed Jul 7, 2016
1 parent 75f64c1 commit 22f8b87
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Called on routes when the location changes, but the route itself neither enters

If `callback` is listed as a 4th argument, this hook will run asynchronously, and the transition will block until `callback` is called.

##### `onLeave()`
##### `onLeave(prevState)`
Called when a route is about to be exited.


Expand Down
4 changes: 2 additions & 2 deletions docs/Glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ A *hash* is a string that represents the hash portion of the URL. It is synonymo
## LeaveHook

```js
type LeaveHook = () => any;
type LeaveHook = (prevState: RouterState) => any;
```

A *leave hook* is a user-defined function that is called when a route is about to be unmounted.
A *leave hook* is a user-defined function that is called when a route is about to be unmounted. It receives the previous [router state](#routerstate) as its first argument.

## Location

Expand Down
6 changes: 4 additions & 2 deletions modules/__tests__/transitionHooks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ describe('When a router enters a branch', function () {
expect(nextState.routes).toContain(InboxRoute)
expect(replace).toBeA('function')
},
onLeave() {
onLeave(prevState) {
expect(this).toBe(InboxRoute)
expect(prevState.routes).toContain(InboxRoute)
}
}

Expand Down Expand Up @@ -173,8 +174,9 @@ describe('When a router enters a branch', function () {
expect(nextState.routes).toContain(DashboardRoute)
expect(replace).toBeA('function')
},
onLeave() {
onLeave(prevState) {
expect(this).toBe(DashboardRoute)
expect(prevState.routes).toContain(DashboardRoute)
},
childRoutes: [ NewsFeedRoute, InboxRoute, RedirectToInboxRoute, MessageRoute, UserRoute ]
}
Expand Down

0 comments on commit 22f8b87

Please sign in to comment.