How to use the connected-react-router.routerMiddleware function in connected-react-router

To help you get started, we’ve selected a few connected-react-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lbryio / lbry-desktop / src / ui / store.js View on Github external
const sharedStateCb = ({ dispatch, getState }) => {
  const state = getState();
  const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state);
  const emailVerified = selectUserVerifiedEmail(state);
  if (syncEnabled && emailVerified) {
    getSavedPassword().then(savedPassword => {
      dispatch(doGetSync(savedPassword));
    });
  }
};

const sharedStateMiddleware = buildSharedStateMiddleware(triggerSharedStateActions, sharedStateFilters, sharedStateCb);
const rootReducer = createRootReducer(history);
const persistedReducer = persistReducer(persistOptions, rootReducer);
const bulkThunk = createBulkThunkMiddleware();
const middleware = [sharedStateMiddleware, routerMiddleware(history), thunk, bulkThunk];
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
  enableBatching(persistedReducer),
  {}, // initial state
  composeEnhancers(applyMiddleware(...middleware))
);

const persistor = persistStore(store);
window.persistor = persistor;

export { store, persistor, history, whiteListedReducers };
github prabaprakash / Awesome-React-Redux-Saga-Boilerplate / src / client / index.js View on Github external
import rootSaga from './sagas/combined';
import createSagaMiddleware from 'redux-saga';
const sagaMiddleware = createSagaMiddleware();

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

import * as actions from './constants';

import { createBrowserHistory } from 'history'
import { routerMiddleware, ConnectedRouter } from 'connected-react-router';
import { Route, Switch } from 'react-router'
const history = createBrowserHistory();

// then run the saga
const store = createStore(createRouteReducers(history), composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware)));
sagaMiddleware.run(rootSaga);
export const action = type => store.dispatch({ type });
action(actions.INITALIZE_APPLICATION);

import AppContainer from './containers/App';
import Error from './components/Error';

render(
  
    
      <div>
        
      </div>
github linweiwei123 / booto / src / index.js View on Github external
function Booto(){

  if(BootoNumber === 1){
    throw new Error('Booto can new only once!');
  }

  BootoNumber = 1;

  this.history = createBrowserHistory();
  this.middleWares = [routerMiddleware(this.history),promiseMiddle];
}
github sysgears / apollo-universal-starter-kit / modules / core / client-react / Main.tsx View on Github external
export const onAppCreate = async (modules: ClientModule, entryModule: NodeModule) => {
  ref.modules = modules;
  ref.client = createApolloClient({
    apiUrl,
    createNetLink: ref.modules.createNetLink,
    createLink: ref.modules.createLink,
    connectionParams: ref.modules.connectionParams,
    clientResolvers: ref.modules.resolvers
  });
  if (entryModule.hot && entryModule.hot.data && entryModule.hot.data.store) {
    ref.store = entryModule.hot.data.store;
    ref.store.replaceReducer(getStoreReducer(history, ref.modules.reducers));
  } else {
    ref.store = createReduxStore(ref.modules.reducers, {}, history, routerMiddleware(history));
  }
};
github TheThingsNetwork / lorawan-stack / pkg / webui / console / store / index.js View on Github external
export default function(history) {
  const middleware = applyMiddleware(
    requestPromiseMiddleware,
    routerMiddleware(history),
    createLogicMiddleware(logics),
  )

  return createStore(connectRouter(history)(reducer), composeEnhancers(middleware))
}
github fusor / mig-ui / src / configureStore.ts View on Github external
const devMode = process.env.DEVMODE || 'local';

const persistConfig = {
  key: 'root',
  storage,
  //whitelist: ['cluster', 'storage', 'plan'],
  whitelist: [],
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

const sagaMiddleware = createSagaMiddleware();

const enhancers = [];
const logger = createLogger({collapsed: true});
const middleware = [thunk, logger, sagaMiddleware, routerMiddleware(history)];

if (devMode === 'local') {
  const devToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION__;

  if (typeof devToolsExtension === 'function') {
    enhancers.push(devToolsExtension());
  }
}
const composedEnhancers = compose(
  applyMiddleware(...middleware),
  ...enhancers
);

export default () => {
  const store = createStore(persistedReducer, composedEnhancers);
  sagaMiddleware.run(rootSaga);
github fttv-project / fttv / src / store / configureStore.ts View on Github external
export default (history: History, initialState?: State) =&gt; {
	const rootReducer = connectRouter(history)(reducer);
	const epicMiddleware = createEpicMiddleware(rootEpic);

	const enhancers = composeWithDevTools(
		applyMiddleware(
			routerMiddleware(history),
			epicMiddleware
		),
		autoRehydrate()
	);

	const store = initialState
		? createStore(rootReducer, initialState, enhancers)
		: createStore(rootReducer, enhancers);

	persistStore(store, {
		keyPrefix: "fttv:",
		whitelist: ["settings", "user"]
	});

	if ((process.env.NODE_ENV === "development") &amp;&amp; module.hot) {
		module.hot.accept("data", () =&gt; {
github unlock-protocol / unlock / paywall / src / createUnlockStore.js View on Github external
locks: defaultLocks,
      modals: defaultModals,
      network: defaultNetwork,
      provider: defaultProvider,
      transactions: defaultTransactions,
      currency: defaultCurrency,
      errors: defaultError,
      walletStatus: defaultWalletStatus,
    },
    {
      provider: Object.keys(config.providers)[0],
    },
    defaultState
  )

  middlewares.push(routerMiddleware(history))

  const composeEnhancers =
    (global.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
      window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
        trace: true,
        traceLimit: 25,
      })) ||
    compose

  return createStore(
    combineReducers(reducers),
    initialState,
    composeEnhancers(applyMiddleware(...middlewares))
  )
}
github ninjadotorg / handshake-app / src / stores / index.js View on Github external
...reducers,
};
const defaultReducer = (s = {}) => s;
const AppReducers = combineReducers(
  Object.keys(defaultStore).reduce((result, key) => {
    return Object.assign({}, result, {
      [key]: reducers[key] ? reducers[key] : defaultReducer,
    });
  }, reducerList),
);

const sagaMiddleware = createSagaMiddleware();

const createStoreWithFirebase = compose(
  reactReduxFirebase(firebase, process.env.firebase),
  composeWithDevTools(applyMiddleware(routerMiddleware(history), thunk, sagaMiddleware)),
)(createStore);

const rootReducer = reduceReducers(AppReducers, dataReducer);
const store = createStoreWithFirebase(connectRouter(history)(rootReducer), defaultStore);

sagaMiddleware.run(rootSaga);

export default store;