Skip to content

Commit 8d90faa

Browse files
author
Sérgio Saquetim
committed
Added definition for the onChange hook on routes that was introduced in version v2.1.0
1 parent 617e37e commit 8d90faa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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)