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: store.js    From one-wallet with Apache License 2.0 6 votes vote down vote up
store = createStore(
  rootReducer(history),
  undefined,
  composeEnhancers(
    applyMiddleware(
      sagaMiddleware,
      routerMiddleware(history)
    )
  )
)
Example #2
Source File: index.js    From react-03.03 with MIT License 6 votes vote down vote up
export function initStore(preloaderState = undefined) {
  return createStore(
    reducer,
    preloaderState,
    composeEnhancers(
      applyMiddleware(
        apiMiddleware,
        ReduxThunk,
        routerMiddleware(history),
        botMiddleware,
        chatMiddleware
      ),
    )
  );
}
Example #3
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
initStore = (preloadedState = {}) => {

    return configureStore({
        reducer: persist,
        middleware: [createLogger(), routerMiddleware(history), chatMiddleware, botMiddleware, UnreadMessageMiddleware, thunk],
        preloadedState,
        devTools: devTools,

    })
}
Example #4
Source File: store.js    From resumeker-fe with MIT License 6 votes vote down vote up
export default function store(preloadedState) {
  const store = createStore(
    rootReducer(history),
    preloadedState,
    applyMiddleware(routerMiddleware(history), thunk, logger)
  );

  return store;
}
Example #5
Source File: configureStore.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
initStore =(preloadedState = {}) => {
    const innitialStore = {};

    const store = createStore(
        persistReducer(persisitConfig, reducer),
        innitialStore,
        compose(applyMiddleware(routerMiddleware(history), logger, loadMiddleware, addMiddleware, deleteChatMiddleware, switchPageMiddleware, chatMiddleware, botMiddleware, apiMiddleware, thunk), devTools),
    );

    const persistor = persistStore(store);

    return {store, persistor};
    //return createStore(reducer, preloadedState, compose(applyMiddleware(logger, botMiddleware), devTools));
    //return createStore(reducer, preloadedState, compose(applyMiddleware(routerMiddleware(history), logger, loadMiddleware, addMiddleware, switchPageMiddleware, chatMiddleware, botMiddleware), devTools));
}
Example #7
Source File: configureStore.js    From loopring-pay with Apache License 2.0 6 votes vote down vote up
// 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 #8
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
initStore = (preloadedState = {}) => {
    const store = createStore(
        /*persistReducer(persistConfig, reducer),*/
        reducer,
        preloadedState,
        compose(applyMiddleware(routerMiddleware(history), logger, botMiddleware, chatMiddleware, apiMiddleware, thunk), devTools),
    );

    /*const persistor = persistStore(store);*/

    return {store, /*persistor*/};
}
Example #9
Source File: configureStore.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: configureStore.js    From HexactaLabs-NetCore_React-Final with Apache License 2.0 6 votes vote down vote up
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 #11
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
function initStore() {
    const initialStore = {};

    return createStore(
        //initReducers,
        initReducers(history),
        initialStore,
        compose(
            //applyMiddleware(...middlewares),
            applyMiddleware(routerMiddleware(history), ...middlewares),
        //window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : () => {},
        //only for Chrome, not for Opera!
        ),
    );
}
Example #12
Source File: store.js    From horondi_admin with MIT License 6 votes vote down vote up
configureStore = () => {
  const sagaMiddleware = createSagaMiddleware();
  const store = createStore(
    rootReducer(history),
    composeWithDevTools(
      applyMiddleware(sagaMiddleware, routerMiddleware(history))
    )
  );
  sagaMiddleware.run(rootSaga);
  return store;
}
Example #13
Source File: store.js    From horondi_client_fe with MIT License 6 votes vote down vote up
configureStore = () => {
  const sagaMiddleware = createSagaMiddleware();
  const store = createStore(
    rootReducer(history),
    composeWithDevTools(applyMiddleware(routerMiddleware(history), sagaMiddleware))
  );
  sagaMiddleware.run(rootSaga);
  return store;
}
Example #14
Source File: render.js    From tunnel-tool with MIT License 6 votes vote down vote up
configureStore = ({ reducers, initialState }) => {
  const reduxMiddlewares = [routerMiddleware(createMemoryHistory())];

  const store = createStore(
    combineReducers({ app: reducers }),
    initialState,
    compose(applyMiddleware(...reduxMiddlewares))
  );

  return { store };
}
Example #15
Source File: index.js    From fhir-app-starter with MIT License 6 votes vote down vote up
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 #16
Source File: configureStore.js    From HexactaLabs-NetCore_React-Initial with Apache License 2.0 6 votes vote down vote up
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 #17
Source File: index.js    From defizap-frontend with GNU General Public License v2.0 6 votes vote down vote up
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 #18
Source File: configureStore.js    From dexwebapp with Apache License 2.0 6 votes vote down vote up
// 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 #19
Source File: configureStore.js    From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 6 votes vote down vote up
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 #20
Source File: render.js    From tunnel-tool with MIT License 6 votes vote down vote up
configureStore = ({ reducers, initialState }) => {
  const history = createHistory();

  // Allow the passed state to be garbage-collected
  //delete window.__PRELOADED_STATE__;
  const store = createStore(
    /***/
    combineReducers({ router: connectRouter(history), app: reducers }),
    initialState,
    /**/
    compose(
      applyMiddleware(routerMiddleware(history)),
      /**/
      typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== "undefined"
        ? window.__REDUX_DEVTOOLS_EXTENSION__()
        : f => f
    )
  );

  return { store, history };
}
Example #21
Source File: index.js    From react-03.03 with MIT License 6 votes vote down vote up
export function initStore (preloadedState = undefined) {
    return createStore(
        reducer, 
        preloadedState, 
        composeEnhancers(applyMiddleware(
            ReduxThunk,
            apiMiddleware,
            routerMiddleware(history), 
            botMiddleware, 
            chatMiddleware
            ))
    )
}
Example #22
Source File: store.js    From substrate-authn-faucet-frontend with GNU General Public License v3.0 6 votes vote down vote up
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 #23
Source File: index.js    From React-Nest-Admin with MIT License 6 votes vote down vote up
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 #24
Source File: configureStore.prod.js    From mern-stack with MIT License 6 votes vote down vote up
configureStore = (initialState) => {
  const store = createStore(
    createRootReducer(history),
    initialState,
    composeEnhancer(
      applyMiddleware(
        routerMiddleware(history),
        reduxThunk.withExtraArgument({ mernApi })
      )
    )
  );

  return store;
}
Example #25
Source File: index.js    From react-03.03 with MIT License 6 votes vote down vote up
// 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 #26
Source File: index.js    From ant-simple-pro with MIT License 5 votes vote down vote up
middlewares = [routerMiddleware(history), sagaMiddleware]
Example #27
Source File: configureStore.prod.js    From brisque-2.0-desktop with MIT License 5 votes vote down vote up
router = routerMiddleware(history)
Example #28
Source File: store.js    From github-azure-demo with MIT License 5 votes vote down vote up
myRouterMiddleware = routerMiddleware(history)
Example #29
Source File: configureStore.dev.js    From brisque-2.0-desktop with MIT License 5 votes vote down vote up
configureStore = (initialState?: stateType) => {
  // 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 = {
    ...actions,
    ...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);

  return store;
}