How to use the connected-react-router/immutable.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 red-gold / react-social-network / src / store / configureStore.prod.ts View on Github external
const persistCallback = () => {
  console.log('rehydration completed')
}

const offlineConfig = {
  ...defaultConfig,
  persist,
  persistAutoRehydrate,
  persistOptions,
  persistCallback,
  offlineStateLens
}

// - Config and create store of redux
let store: redux.Store = redux.createStore(rootReducer(history), fromJS(initialState), redux.compose(
  redux.applyMiddleware(thunk, routerMiddleware(history), sagaMiddleware), offline(offlineConfig)
))

export default {store, runSaga: sagaMiddleware.run, close: () => store.dispatch(END), history}
github mozilla / delivery-console / src / index.js View on Github external
import App from 'console/components/App';
import { SENTRY_PUBLIC_DSN } from 'console/settings';
import createRootReducer from 'console/state/reducer';

if (SENTRY_PUBLIC_DSN) {
  Raven.config(SENTRY_PUBLIC_DSN)
    .addPlugin(consolePlugin, window.console, { levels: ['warn', 'error'] })
    .install();
}

// Add support for Redux Devtools
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const history = createBrowserHistory();

const middleware = [routerMiddleware(history), thunk];

const rootReducer = createRootReducer(history);

const store = createStore(
  rootReducer,
  rootReducer(undefined, { type: 'initial' }),
  composeEnhancers(applyMiddleware(...middleware)),
);

ReactDOM.render(
  
    
  ,
  document.getElementById('root'),
);
github PacktPublishing / Redux-Quick-Start-Guide / Chapter03 / app / configureStore.js View on Github external
export default function configureStore(initialState = {}, history) {
  const middlewares = [routerMiddleware(history)];

  const enhancers = [applyMiddleware(...middlewares)];

  const store = createStore(
    createReducer(),
    fromJS(initialState),
    compose(...enhancers),
  );

  // Extensions
  store.injectedReducers = {};

  return store;
}
github supasate / connected-react-router / examples / immutable / src / configureStore.js View on Github external
export default function configureStore(preloadedState) {
  const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
  const store = createStore(
    createRootReducer(history),
    preloadedState,
    composeEnhancer(
      applyMiddleware(
        routerMiddleware(history),
      ),
    ),
  )

  // Hot reloading
  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('./reducers', () => {
      store.replaceReducer(createRootReducer(history));
    });
  }

  return store
}
github Armour / express-webpack-react-redux-typescript-boilerplate / frontend / src / store / index.tsx View on Github external
export default (history: History, initialState: IGlobalState | {}): Store => {
  // Create the saga middleware
  const sagaMiddleware = createSagaMiddleware();

  // Enhancer
  const composeEnhancers =
    typeof window === 'object' && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
      (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
        serialize: {
          immutable: Immutable,
        },
      }) : compose;
  const enhancer = composeEnhancers(
    applyMiddleware(routerMiddleware(history), sagaMiddleware, logger),
  );

  // Store
  const store = createStore(createRootReducer(history), initialState, enhancer);
  sagaMiddleware.run(sagas);

  // Enable Webpack hot module replacement for reducers
  if (module.hot) {
    module.hot.accept('../reducers', () => {
      store.replaceReducer(createRootReducer(history));
    });
  }

  return store;
};
github red-gold / react-social-network / src / store / configureStore.dev.ts View on Github external
return state.toJS()
  }
})

const sagaMiddleware = createSagaMiddleware()
// - initial state
let initialState = {

}

// - Config and create store of redux
const composeEnhancers = composeWithDevTools({
      // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
    })
let store: Store = createStore(rootReducer(history), fromJS(initialState), composeEnhancers(
  applyMiddleware(logger,thunk, routerMiddleware(history), sagaMiddleware)
))

export default {store, runSaga: sagaMiddleware.run, close: () => store.dispatch(END), history}
github stampzilla / stampzilla-go / nodes / stampzilla-magicmirror / web / src / store.js View on Github external
import { createStore, applyMiddleware, compose } from 'redux'
import { routerMiddleware } from 'connected-react-router/immutable'
import thunk from 'redux-thunk'
import createHistory from 'history/createBrowserHistory'
import rootReducer from './ducks'
import { Map } from 'immutable'

export const history = createHistory()

const initialState = Map({})
const enhancers = []
const middleware = [thunk, routerMiddleware(history)]

if (process.env.NODE_ENV === 'development') {
  const devToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION__

  if (typeof devToolsExtension === 'function') {
    enhancers.push(devToolsExtension())
  }
}

const composedEnhancers = compose(
  applyMiddleware(...middleware),
  ...enhancers
)

export default createStore(
  rootReducer(history),
github hahoocn / react-mobile-boilerplate / src / store.js View on Github external
export default function configureStore(initialState, history) {
  const composeEnhancers = (typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;
  const middleware = composeEnhancers(
    applyMiddleware(
      thunk,
      routerMiddleware(history)
    )
  );

  const store = createStore(rootReducer(history), fromJS(initialState), middleware);

  return store;
}
github secret-tech / frontend-boilerplate / src / redux / configureStore.js View on Github external
const configureStoreDev = () => {
  const middlewares = [
    sagaMiddleware,
    routerMiddleware(history),
    loggerMiddleware
  ];

  const store = createStore(
    connectRouter(history)(rootReducer),
    initialState,
    applyMiddleware(...middlewares)
  );

  if (module.hot) {
    module.hot.accept('./rootReducer', () => {
      const nextReducer = require('./rootReducer').default;
      store.replaceReducer(nextReducer);
    });
  }
github gilmarsquinelato / i18n-manager / renderer / config / redux.ts View on Github external
export default (history: History) => {
  const sagaMiddleware = createSagaMiddleware();

  const enhancer = composeWithDevTools(applyMiddleware(
    sagaMiddleware,
    routerMiddleware(history),
  ));

  const store = createStore(
    connectRouter(history)(rootReducer),
    enhancer,
  );
  let sagaTask = sagaMiddleware.run(rootSaga);

  const hot = (module as any).hot;
  if (hot) {
    hot.accept('./rootReducer', () => {
      const reducer = require('./rootReducer').default;
      store.replaceReducer(connectRouter(history)(reducer));
    });

    hot.accept('./rootSaga', () => {