Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (initialState = DEFAULT_STATE) => {
// We do not want middlewares like redux-logger to get
// fired on the server side
if (isServer) {
return createStore(reducers, initialState, applyMiddleware(thunk.withExtraArgument(socket)));
} else {
initialState = deepmerge(
load({ states: localStorageStates, namespace: packageJson.name }),
initialState,
);
return createStore(
reducers,
initialState,
applyMiddleware(logger,
save({ states: localStorageStates, namespace: packageJson.name }),
thunk.withExtraArgument(socket)),
);
}
};
export default function configureStore() {
// In SSR, we can't access localStorage, so we need to build the store without
// save/load support. I think this is fine though.
let store;
if (typeof window === 'undefined') {
store = createStore(rootReducer);
} else {
store = createStore(
rootReducer,
load(reduxLocalStorageConfig),
applyMiddleware(save(reduxLocalStorageConfig))
);
}
return store;
}
export default function configureStore() {
const store = createStore(
rootReducer,
load(reduxLocalStorageConfig),
compose(
applyMiddleware(focusManagerMiddleware, save(reduxLocalStorageConfig)),
DevTools.instrument()
)
);
// Allow direct access to the store, for debugging/testing
window.store = store;
return store;
}
export function getStorageData( states = [], preloadedState = {} ) {
return load( {
states,
namespace,
preloadedState,
disableWarnings: true,
} );
}
const composeEnhancers =
(window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;
const middleware = [
thunkMiddleware,
save({
namespace: APP_LS_KEY,
states: storageStates
}),
!PRODUCTION && loggerMiddleware
].filter(Boolean);
const enhancer = composeEnhancers(applyMiddleware(...middleware));
const store = createStore(
rootReducer,
load({
namespace: APP_LS_KEY,
states: storageStates,
preloadedState: {
auth: { ...initialAuthState },
profiles: { ...initialProfilesState },
favourites: { ...initialFavouritesState }
},
disableWarnings: true
}),
enhancer
);
return store;
};
export default function configureStore(history) {
const middleware = applyMiddleware(routerMiddleware(history), spyMiddleware, save)
const enhancer = composeEnhancers(middleware)
return createStore(
combineReducers({
app: appReducer,
router: routerReducer,
}),
makeLoader(),
enhancer,
)
}