mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 11:07:32 +08:00
Merge pull request #24311 from mykolas/master
react-router-redux typings update for createMatchSelector function
This commit is contained in:
4
types/react-router-redux/index.d.ts
vendored
4
types/react-router-redux/index.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user