Udpate react-router-redux
This commit is contained in:
@ -3,7 +3,11 @@ import Rx from 'rx';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
import { Router } from 'react-router';
|
import { Router } from 'react-router';
|
||||||
import { routeReducer as routing, syncHistory } from 'react-router-redux';
|
import {
|
||||||
|
routerMiddleware,
|
||||||
|
routerReducer as routing,
|
||||||
|
syncHistoryWithStore
|
||||||
|
} from 'react-router-redux';
|
||||||
import { render } from 'redux-epic';
|
import { render } from 'redux-epic';
|
||||||
import { createHistory } from 'history';
|
import { createHistory } from 'history';
|
||||||
|
|
||||||
@ -33,10 +37,9 @@ initialState.app.csrfToken = csrfToken;
|
|||||||
const serviceOptions = { xhrPath: '/services', context: { _csrf: csrfToken } };
|
const serviceOptions = { xhrPath: '/services', context: { _csrf: csrfToken } };
|
||||||
|
|
||||||
const history = createHistory();
|
const history = createHistory();
|
||||||
const routingMiddleware = syncHistory(history);
|
|
||||||
|
|
||||||
const devTools = window.devToolsExtension ? window.devToolsExtension() : f => f;
|
const devTools = window.devToolsExtension ? window.devToolsExtension() : f => f;
|
||||||
const shouldRouterListenForReplays = !!window.devToolsExtension;
|
const adjustUrlOnReplay = !!window.devToolsExtension;
|
||||||
|
|
||||||
const sagaOptions = {
|
const sagaOptions = {
|
||||||
isDev,
|
isDev,
|
||||||
@ -48,19 +51,17 @@ const sagaOptions = {
|
|||||||
|
|
||||||
createApp({
|
createApp({
|
||||||
history,
|
history,
|
||||||
|
syncHistoryWithStore,
|
||||||
|
syncOptions: { adjustUrlOnReplay },
|
||||||
serviceOptions,
|
serviceOptions,
|
||||||
initialState,
|
initialState,
|
||||||
middlewares: [ routingMiddleware ],
|
middlewares: [ routerMiddleware(history) ],
|
||||||
sagas: [...sagas ],
|
sagas: [...sagas ],
|
||||||
sagaOptions,
|
sagaOptions,
|
||||||
reducers: { routing },
|
reducers: { routing },
|
||||||
enhancers: [ devTools ]
|
enhancers: [ devTools ]
|
||||||
})
|
})
|
||||||
.doOnNext(({ store }) => {
|
.doOnNext(({ store }) => {
|
||||||
if (shouldRouterListenForReplays && store) {
|
|
||||||
log('routing middleware listening for replays');
|
|
||||||
routingMiddleware.listenForReplays(store);
|
|
||||||
}
|
|
||||||
if (module.hot && typeof module.hot.accept === 'function') {
|
if (module.hot && typeof module.hot.accept === 'function') {
|
||||||
module.hot.accept('../common/app', function() {
|
module.hot.accept('../common/app', function() {
|
||||||
saveToColdStorage(store.getState());
|
saveToColdStorage(store.getState());
|
||||||
|
@ -23,6 +23,7 @@ const routes = { components: App, ...childRoutes };
|
|||||||
// createApp(settings: {
|
// createApp(settings: {
|
||||||
// location?: Location|String,
|
// location?: Location|String,
|
||||||
// history?: History,
|
// history?: History,
|
||||||
|
// syncHistoryWithStore?: ((history, store) => history) = (x) => x,
|
||||||
// initialState?: Object|Void,
|
// initialState?: Object|Void,
|
||||||
// serviceOptions?: Object,
|
// serviceOptions?: Object,
|
||||||
// middlewares?: Function[],
|
// middlewares?: Function[],
|
||||||
@ -35,6 +36,8 @@ const routes = { components: App, ...childRoutes };
|
|||||||
export default function createApp({
|
export default function createApp({
|
||||||
location,
|
location,
|
||||||
history,
|
history,
|
||||||
|
syncHistoryWithStore = (x) => x,
|
||||||
|
syncOptions = {},
|
||||||
initialState,
|
initialState,
|
||||||
serviceOptions = {},
|
serviceOptions = {},
|
||||||
middlewares: sideMiddlewares = [],
|
middlewares: sideMiddlewares = [],
|
||||||
@ -69,6 +72,9 @@ export default function createApp({
|
|||||||
// call enhanced createStore function with reducer and initialState
|
// call enhanced createStore function with reducer and initialState
|
||||||
// to create store
|
// to create store
|
||||||
const store = compose(...enhancers)(createStore)(reducer, initialState);
|
const store = compose(...enhancers)(createStore)(reducer, initialState);
|
||||||
|
// sync history client side with store.
|
||||||
|
// server side this is an identity function and history is undefined
|
||||||
|
history = syncHistoryWithStore(history, store, syncOptions);
|
||||||
|
|
||||||
// createRouteProps({
|
// createRouteProps({
|
||||||
// redirect: LocationDescriptor,
|
// redirect: LocationDescriptor,
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
"react-redux": "^4.0.6",
|
"react-redux": "^4.0.6",
|
||||||
"react-router": "^2.0.0",
|
"react-router": "^2.0.0",
|
||||||
"react-router-bootstrap": "~0.23.1",
|
"react-router-bootstrap": "~0.23.1",
|
||||||
"react-router-redux": "^2.1.0",
|
"react-router-redux": "^4.0.5",
|
||||||
"react-toastr": "^2.4.0",
|
"react-toastr": "^2.4.0",
|
||||||
"react-youtube": "^6.1.0",
|
"react-youtube": "^6.1.0",
|
||||||
"redux": "^3.0.5",
|
"redux": "^3.0.5",
|
||||||
@ -154,7 +154,7 @@
|
|||||||
"sinon": "^1.17.3",
|
"sinon": "^1.17.3",
|
||||||
"sort-keys": "^1.1.1",
|
"sort-keys": "^1.1.1",
|
||||||
"tap-spec": "^4.1.1",
|
"tap-spec": "^4.1.1",
|
||||||
"tape": "^4.2.2"
|
"tape": "^4.2.2",
|
||||||
"webpack": "^1.9.12",
|
"webpack": "^1.9.12",
|
||||||
"webpack-dev-server": "^1.14.0",
|
"webpack-dev-server": "^1.14.0",
|
||||||
"webpack-manifest-plugin": "^1.0.0",
|
"webpack-manifest-plugin": "^1.0.0",
|
||||||
|
Reference in New Issue
Block a user