connected-react-router#routerMiddleware JavaScript Examples
The following examples show how to use
connected-react-router#routerMiddleware.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From fhir-app-starter with MIT License | 6 votes |
export default function configureStore(initialState = {}, history) {
let composeEnhancers = compose;
const reduxSagaMonitorOptions = {};
// If Redux Dev Tools and Saga Dev Tools Extensions are installed, enable them
/* istanbul ignore next */
if (process.env.NODE_ENV !== 'production' && typeof window === 'object') {
/* eslint-disable no-underscore-dangle */
if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({});
// NOTE: Uncomment the code below to restore support for Redux Saga
// Dev Tools once it supports redux-saga version 1.x.x
// if (window.__SAGA_MONITOR_EXTENSION__)
// reduxSagaMonitorOptions = {
// sagaMonitor: window.__SAGA_MONITOR_EXTENSION__,
// };
/* eslint-enable */
}
const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
// Create the store with two middlewares
// 1. sagaMiddleware: Makes redux-sagas work
// 2. routerMiddleware: Syncs the location/URL path to the state
const middlewares = [sagaMiddleware, routerMiddleware(history), logger];
const enhancers = [applyMiddleware(...middlewares)];
const store = createStore(rootReducer, initialState, composeEnhancers(...enhancers));
// Extensions
store.runSaga = sagaMiddleware.run;
store.runSaga(sagas);
return store;
}
Example #2
Source File: store.js From resumeker-fe with MIT License | 6 votes |
export default function store(preloadedState) {
const store = createStore(
rootReducer(history),
preloadedState,
applyMiddleware(routerMiddleware(history), thunk, logger)
);
return store;
}
Example #3
Source File: index.js From defizap-frontend with GNU General Public License v2.0 | 6 votes |
configureStore = (initialState, history) => {
const middlewares = [thunk, routerMiddleware(history)];
const storeEnhancers = [];
const isDev = process.env.NODE_ENV !== 'production';
if (isDev) {
// allow devs to use their own plugged in browser redux dev tool instead of the builtin component
const devTools = DevTools();
const devToolsEnhancer = window.__REDUX_DEVTOOLS_EXTENSION__
? window.__REDUX_DEVTOOLS_EXTENSION__()
: devTools.instrument();
storeEnhancers.push(devToolsEnhancer);
}
const middlewareEnhancer = applyMiddleware(...middlewares);
storeEnhancers.unshift(middlewareEnhancer);
const store = createStore(
rootReducer(history),
initialState,
compose(...storeEnhancers)
);
if (isDev && module.hot && module.hot.accept) {
module.hot.accept('../reducers', () => {
const nextRootReducer = lazy(() => import('../reducers'));
store.replaceReducer(nextRootReducer);
});
}
return store;
}
Example #4
Source File: configureStore.js From HexactaLabs-NetCore_React-Initial with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #5
Source File: configureStore.js From dexwebapp with Apache License 2.0 | 6 votes |
// Setting preloadedState is still behind setting initState in each reducer
export default function configureStore(preloadedState) {
const composeEnhancer =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
createRootReducer(history),
preloadedState,
composeEnhancer(
applyMiddleware(
thunk,
routerMiddleware(history),
trackingMiddleware(tracker)
)
)
);
// Hot reloading
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
store.replaceReducer(createRootReducer(history));
});
}
return store;
}
Example #6
Source File: configureStore.js From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
productType,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #7
Source File: store.js From substrate-authn-faucet-frontend with GNU General Public License v3.0 | 6 votes |
configureStore = () => {
const middlewares = Array.prototype.concat(
[],
[thunk, routerMiddleware(history)],
process.env.NODE_ENV === 'development' ? [createLogger()] : []
);
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const enhancer = composeEnhancers(
applyMiddleware(...middlewares),
responsiveStoreEnhancer
);
store = createStore(resetEnhancer(createReducer(history)), enhancer);
store.asyncReducers = {};
return {
store,
history
};
}
Example #8
Source File: index.js From React-Nest-Admin with MIT License | 6 votes |
export default function configureStore() {
const middlewares = [ReduxThunk, routerMiddleware(history)];
const enhancers = [applyMiddleware(...middlewares)];
// use redux devtool, redux-thunk middleware
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
connectRouter(history)(persistedReducer),
composeEnhancers(...enhancers)
);
const persistor = persistStore(store);
return { store, persistor };
}
Example #9
Source File: index.js From react-03.03 with MIT License | 6 votes |
// const reducer = function(store = {counter:1},action) {
// console.log('action', action)
// // switch(action.type){
// // case "TEST" : console.log("this is action TEST")
// // }
// return {
// ...store,
// counter: store.counter + 1
// }
// }
export function initStore (preloadedState = undefined){
return createStore(
reducer,
preloadedState,
composeEnhancers(
applyMiddleware(
ReduxThunk,
routerMiddleware(history),
botMiddleware,
chatMiddleware
)
)
)
}
Example #10
Source File: store.js From react-14.01 with MIT License | 6 votes |
initStore = (preloadedState = {}) => {
return configureStore({
reducer: persist,
middleware: [createLogger(), routerMiddleware(history), chatMiddleware, botMiddleware, UnreadMessageMiddleware, thunk],
preloadedState,
devTools: devTools,
})
}
Example #11
Source File: store.js From horondi_admin with MIT License | 6 votes |
configureStore = () => {
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
rootReducer(history),
composeWithDevTools(
applyMiddleware(sagaMiddleware, routerMiddleware(history))
)
);
sagaMiddleware.run(rootSaga);
return store;
}
Example #12
Source File: store.js From horondi_client_fe with MIT License | 6 votes |
configureStore = () => {
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
rootReducer(history),
composeWithDevTools(applyMiddleware(routerMiddleware(history), sagaMiddleware))
);
sagaMiddleware.run(rootSaga);
return store;
}
Example #13
Source File: configureStore.js From HexactaLabs-NetCore_React-Final with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
product,
productType,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #14
Source File: configureStore.js From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
producttype,
store,
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(applyMiddleware(...middleware), ...enhancers)
);
}
Example #15
Source File: configureStore.js From loopring-pay with Apache License 2.0 | 6 votes |
// Setting preloadedState is still behind setting initState in each reducer
export default function configureStore(preloadedState) {
const composeEnhancer =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
createRootReducer(history),
preloadedState,
composeEnhancer(applyMiddleware(thunk, routerMiddleware(history)))
);
// Hot reloading
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept("./reducers", () => {
store.replaceReducer(createRootReducer(history));
});
}
return store;
}
Example #16
Source File: configureStore.js From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
store,
producttype
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #17
Source File: store.js From one-wallet with Apache License 2.0 | 6 votes |
store = createStore(
rootReducer(history),
undefined,
composeEnhancers(
applyMiddleware(
sagaMiddleware,
routerMiddleware(history)
)
)
)
Example #18
Source File: configureStore.dev.js From mern-stack with MIT License | 6 votes |
configureStore = (initialState) => {
const store = createStore(
createRootReducer(history),
initialState,
composeEnhancer(
applyMiddleware(
routerMiddleware(history),
reduxThunk.withExtraArgument({ mernApi })
)
)
);
// Hot reload reducers (requires Webpack or Browserify HMR to be enabled)
if (module.hot) {
module.hot.accept('./reducers', () =>
store.replaceReducer(createRootReducer(history))
);
}
return store;
}
Example #19
Source File: render.js From tunnel-tool with MIT License | 6 votes |
configureStore = ({ reducers, initialState }) => {
const reduxMiddlewares = [routerMiddleware(createMemoryHistory())];
const store = createStore(
combineReducers({ app: reducers }),
initialState,
compose(applyMiddleware(...reduxMiddlewares))
);
return { store };
}
Example #20
Source File: configureStore.js From QiskitFlow with Apache License 2.0 | 5 votes |
export default function configureStore(initialState = {}, history) {
let composeEnhancers = compose;
const reduxSagaMonitorOptions = {};
// If Redux Dev Tools and Saga Dev Tools Extensions are installed, enable them
/* istanbul ignore next */
if (process.env.NODE_ENV !== 'production' && typeof window === 'object') {
/* eslint-disable no-underscore-dangle */
if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({});
// NOTE: Uncomment the code below to restore support for Redux Saga
// Dev Tools once it supports redux-saga version 1.x.x
// if (window.__SAGA_MONITOR_EXTENSION__)
// reduxSagaMonitorOptions = {
// sagaMonitor: window.__SAGA_MONITOR_EXTENSION__,
// };
/* eslint-enable */
}
const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
// Create the store with two middlewares
// 1. sagaMiddleware: Makes redux-sagas work
// 2. routerMiddleware: Syncs the location/URL path to the state
const middlewares = [sagaMiddleware, routerMiddleware(history)];
const enhancers = [applyMiddleware(...middlewares)];
const store = createStore(
createReducer(),
initialState,
composeEnhancers(...enhancers),
);
// Extensions
store.runSaga = sagaMiddleware.run;
store.injectedReducers = {}; // Reducer registry
store.injectedSagas = {}; // Saga registry
// Make reducers hot reloadable, see http://mxs.is/googmo
/* istanbul ignore next */
if (module.hot) {
module.hot.accept('./reducers', () => {
store.replaceReducer(createReducer(store.injectedReducers));
});
}
return store;
}
Example #21
Source File: store.js From juggernaut-desktop with MIT License | 5 votes |
router = routerMiddleware(history)
Example #22
Source File: configureStore.dev.js From NoteMaster with GNU General Public License v3.0 | 5 votes |
configureStore = (initialState?: any) => {
// Redux Configuration
const middleware = [];
const enhancers = [];
// Thunk Middleware
middleware.push(thunk);
// Logging Middleware
const logger = createLogger({
level: 'info',
collapsed: true
});
// Skip redux logs in console during the tests
if (process.env.NODE_ENV !== 'test') {
middleware.push(logger);
}
// Router Middleware
const router = routerMiddleware(history);
middleware.push(router);
// Redux DevTools Configuration
const actionCreators = {
...routerActions
};
// If Redux DevTools Extension is installed use it, otherwise use Redux compose
/* eslint-disable no-underscore-dangle */
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Options: http://extension.remotedev.io/docs/API/Arguments.html
actionCreators
})
: compose;
/* eslint-enable no-underscore-dangle */
// Apply Middleware & Compose Enhancers
enhancers.push(applyMiddleware(...middleware));
const enhancer = composeEnhancers(...enhancers);
// Create Store
const store = createStore(rootReducer, initialState, enhancer);
if (module.hot) {
module.hot.accept(
'../redux/rootReducer',
// eslint-disable-next-line global-require
() => store.replaceReducer(require('../redux/rootReducer').default)
);
}
return store;
}
Example #23
Source File: store.js From beluga with GNU General Public License v3.0 | 5 votes |
store = createStore( createRootReducer(history), compose( applyMiddleware(routerMiddleware(history), thunk) ) )
Example #24
Source File: store.js From relay_11 with MIT License | 5 votes |
middlewares = [thunk, routerMiddleware(history)]
Example #25
Source File: index.js From gobench with Apache License 2.0 | 5 votes |
routeMiddleware = routerMiddleware(history)
Example #26
Source File: configureStore.js From hackchat-client with Do What The F*ck You Want To Public License | 5 votes |
/**
* Exports the main Redux Store reference using passed params
* @param {object} initialState Initial store data
* @param {object} history React history object
* @public
* @return {redux#Store}
*/
export default function configureStore(initialState = {}, history) {
let composeEnhancers = compose;
const reduxSagaMonitorOptions = {};
if (process.env.NODE_ENV !== 'production' && typeof window === 'object') {
/* eslint-disable no-underscore-dangle */
if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({});
/* eslint-enable */
}
const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
const middlewares = [sagaMiddleware, routerMiddleware(history)];
const enhancers = [applyMiddleware(...middlewares)];
const store = createStore(
createReducer(),
initialState,
composeEnhancers(...enhancers),
);
// Add extensions
store.runSaga = sagaMiddleware.run;
store.injectedReducers = {}; // Reducer registry
store.injectedSagas = {}; // Saga registry
// Add hot reload if we are in dev mode
if (module.hot) {
module.hot.accept('./reducers', () => {
store.replaceReducer(createReducer(store.injectedReducers));
});
}
return store;
}
Example #27
Source File: store.js From react-14.01 with MIT License | 5 votes |
initStore = (preloadedState = {}) => {
return createStore(reducer, preloadedState, compose(applyMiddleware(routerMiddleware(history), logger, chatMiddleware, botMiddleware, apiMiddleware, thunk), devTools));
}
Example #28
Source File: index.jsx From agent with MIT License | 5 votes |
store = createStore( rootReducer(history), { ...getAuthState() }, composeWithDevTools(applyMiddleware(thunk, routerMiddleware(history))) )
Example #29
Source File: index.js From ant-simple-pro with MIT License | 5 votes |
middlewares = [routerMiddleware(history), sagaMiddleware]