From 48f543f2e44fc7b5cebabb3ed18f5a064945b59a Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Wed, 24 Feb 2016 09:16:56 +0700 Subject: [PATCH] update support 4.0.0 --- react-router-redux/react-router-redux-tests.ts | 15 +++++---------- react-router-redux/react-router-redux.d.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/react-router-redux/react-router-redux-tests.ts b/react-router-redux/react-router-redux-tests.ts index 98fcdca1be..50978fafd4 100644 --- a/react-router-redux/react-router-redux-tests.ts +++ b/react-router-redux/react-router-redux-tests.ts @@ -6,15 +6,10 @@ import { createStore, combineReducers, applyMiddleware } from 'redux'; import { browserHistory } from 'react-router'; -import { syncHistory, routeReducer } from 'react-router-redux'; +import { syncHistoryWithStore, routerReducer } from 'react-router-redux'; -const reducer = combineReducers({ routing: routeReducer }); +const reducer = combineReducers({ routing: routerReducer }); +const store = createStore(reducer); -// Sync dispatched route actions to the history -const reduxRouterMiddleware = syncHistory(browserHistory); -const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware)(createStore); - -const store = createStoreWithMiddleware(reducer); - -// Required for replaying actions from devtools to -reduxRouterMiddleware.listenForReplays(store); +// Create an enhanced history that syncs navigation events with the store +const history = syncHistoryWithStore(browserHistory, store) diff --git a/react-router-redux/react-router-redux.d.ts b/react-router-redux/react-router-redux.d.ts index 7248fb3afc..42d34baf64 100644 --- a/react-router-redux/react-router-redux.d.ts +++ b/react-router-redux/react-router-redux.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-router-redux v2.1.0 +// Type definitions for react-router-redux v4.0.0 // Project: https://github.com/rackt/react-router-redux // Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -10,15 +10,15 @@ declare namespace ReactRouterRedux { import R = Redux; import H = HistoryModule; - const TRANSITION: string; - const UPDATE_LOCATION: string; + const CALL_HISTORY_METHOD: string; + const LOCATION_CHANGE: string; const push: PushAction; const replace: ReplaceAction; const go: GoAction; const goBack: GoForwardAction; const goForward: GoBackAction; - const routeActions: RouteActions; + const routerActions: RouteActions; type LocationDescriptor = H.Location | H.Path; type PushAction = (nextLocation: LocationDescriptor) => void; @@ -34,13 +34,13 @@ declare namespace ReactRouterRedux { goForward: GoForwardAction; goBack: GoBackAction; } - interface HistoryMiddleware extends R.Middleware { - listenForReplays(store: R.Store, selectLocationState?: Function): void; + interface HistoryMiddleware extends H.History { unsubscribe(): void; } - function routeReducer(state?: any, options?: any): R.Reducer; - function syncHistory(history: H.History): HistoryMiddleware; + function routerReducer(state?: any, options?: any): R.Reducer; + function syncHistoryWithStore(history: H.History, store: R.Store, options?: any): HistoryMiddleware; + function routerMiddleware(history: H.History): Function; } declare module "react-router-redux" {