Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}
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'),
);
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;
}
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
}
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;
};
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}
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),
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;
}
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);
});
}
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', () => {