Merge pull request #24311 from mykolas/master

react-router-redux typings update for createMatchSelector function
This commit is contained in:
Mine Starks
2018-03-28 08:33:33 -07:00
committed by GitHub
2 changed files with 9 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux
// Definitions by: Huy Nguyen <https://github.com/huy-nguyen>
// Shoya Tanaka <https://github.com/8398a7>
// Mykolas <https://github.com/mykolas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
@@ -19,6 +20,7 @@ import {
LocationDescriptor
} from 'history';
import * as React from 'react';
import { match } from 'react-router';
export interface ConnectedRouterProps<State> {
store?: Store<State>;
@@ -77,3 +79,5 @@ export interface LocationChangeAction {
}
export function routerMiddleware(history: History): Middleware;
export function createMatchSelector(path: string): (state: { router: RouterState }) => match<{}> | null;

View File

@@ -7,7 +7,7 @@ import { Provider } from 'react-redux';
import createHistory from 'history/createBrowserHistory';
import { Route } from 'react-router';
import { ConnectedRouter, routerReducer, routerMiddleware, push, RouterState } from 'react-router-redux';
import { ConnectedRouter, routerReducer, routerMiddleware, push, RouterState, createMatchSelector } from 'react-router-redux';
// Create a history of your choosing (we're using a browser history in this case)
const history = createHistory();
@@ -44,3 +44,7 @@ ReactDOM.render(
// Now you can dispatch navigation actions from anywhere!
store.dispatch(push('/foo'));
// And match location path using createMatchSelector
const matchSelector = createMatchSelector('/:foo');
const match = matchSelector(store.getState());