Skip to content

Commit 42ec24e

Browse files
authored
Merge pull request #6 from megothss/master
Added definition for the onChange hook on routes
2 parents 9fd1b2e + 6cdd4b9 commit 42ec24e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Use the command `typings install react-router --save`.
77

88
You're code should look pretty much the same the javascript with one exception.
99
When a component is used with a `Route` component it injects several property values.
10-
To type this the `IInjectableProps` interface has all the properties defined that injecting will add.
10+
To type this the `IInjectedProps` interface has all the properties defined that injecting will add.
1111

12-
To use it extend your current Property interface with `IInjectableProps`.
12+
To use it extend your current Property interface with `IInjectedProps`.
1313

1414
```typescript
1515
import React from 'react';

react-router.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,13 @@ declare module ReactRouter {
534534
*/
535535
onEnter?: EnterHook;
536536

537+
/**
538+
* Called on routes when the location changes, but the route itself neither enters or leaves. For example, this will be called when a route's children change, or when the location query changes. It provides the previous router state, the next router state, and a function to redirect to another path. this will be the route instance that triggered the hook.
539+
*
540+
* If callback is listed as a 4th argument, this hook will run asynchronously, and the transition will block until callback is called.
541+
*/
542+
onChange?: ChangeHook;
543+
537544
/**
538545
* Called when a route is about to be exited.
539546
*/
@@ -551,6 +558,8 @@ declare module ReactRouter {
551558

552559
type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => any;
553560

561+
type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback?: Function) => any;
562+
554563
type RedirectFunction = (state: LocationState, pathname: Pathname | Path, query?: Query) => void;
555564

556565
type LocationState = Object;

0 commit comments

Comments
 (0)