@reduxjs/toolkit#configureStore JavaScript Examples
The following examples show how to use
@reduxjs/toolkit#configureStore.
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: test-utils.js From Simplify-Testing-with-React-Testing-Library with MIT License | 7 votes |
function render(
ui,
{
initialState,
store = configureStore({
reducer: { retail: retailReducer },
preloadedState: initialState
}),
...renderOptions
} = {}
) {
function Wrapper({ children }) {
return <Provider store={store}>{children}</Provider>
}
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions })
}
Example #2
Source File: store.js From juggernaut-desktop with MIT License | 6 votes |
configuredStore = initialState => {
// Create Store
const store = configureStore({
reducer: rootReducer,
preloadedState: initialState,
middleware,
devTools
});
if (process.env.NODE_ENV === 'development' && module.hot) {
module.hot.accept(
'./rootReducer',
// eslint-disable-next-line global-require
() => store.replaceReducer(require('./rootReducer').default)
);
}
return store;
}
Example #3
Source File: store.js From cra-template-redux-auth-starter with MIT License | 6 votes |
export default function configureAppStore(preloadedState) {
const sagaMiddleware = createSagaMiddleware();
const store = configureStore({
reducer: rootReducer,
middleware: [...getDefaultMiddleware(), sagaMiddleware],
preloadedState,
})
sagaMiddleware.run(rootSaga)
if (process.env.NODE_ENV !== 'production' && module.hot) {
module.hot.accept('app/rootReducers', () => store.replaceReducer(rootReducer))
}
return store
}
Example #4
Source File: index.js From telar-cli with MIT License | 6 votes |
export default function configureAppStore(preloadedState) {
const store = configureStore({
reducer: rootReducer,
middleware: [loggerMiddleware, ...getDefaultMiddleware()],
preloadedState,
enhancers: [monitorReducersEnhancer]
})
if (process.env.NODE_ENV !== 'production' && module.hot) {
module.hot.accept('./reducers', () => store.replaceReducer(rootReducer))
}
return store
}
Example #5
Source File: index.js From ocp-advisor-frontend with Apache License 2.0 | 6 votes |
getStore = (useLogger) =>
configureStore({
reducer,
middleware: (getDefaultMiddleware) => {
const middleware = getDefaultMiddleware().concat(
SmartProxyApi.middleware,
AmsApi.middleware,
Acks.middleware,
notificationsMiddleware({
errorTitleKey: ['message'],
errorDescriptionKey: ['response.data.detail'],
})
);
if (useLogger) {
middleware.concat(logger);
}
return middleware;
},
})
Example #6
Source File: reduxDecorator.jsx From simplQ-frontend with GNU General Public License v3.0 | 6 votes |
reduxDecorator = (Story, context) => {
const { state } = context.parameters;
const store = configureStore({
reducer: rootReducer,
preloadedState: state,
});
store.dispatch = action('dispatch');
const Decorator = () => {
return (
<Provider store={store}>
<Story />
</Provider>
);
};
return <Decorator />;
}
Example #7
Source File: index.js From simplQ-frontend with GNU General Public License v3.0 | 6 votes |
store = configureStore({
reducer: rootReducer,
middleware: getDefaultMiddleware({
serializableCheck: {
// Ignore auth in async thunks
ignoredActionPaths: ['meta.arg.auth'],
},
}),
})
Example #8
Source File: configureStore.js From Healthyhood with MIT License | 6 votes |
export default function () {
return configureStore({
reducer: rootReducer,
middleware: [
...getDefaultMiddleware(), // returns THUNK and compose w/ DevTools
logger,
apiCall,
],
});
}
Example #9
Source File: index.js From use-shopping-cart with MIT License | 6 votes |
export function createShoppingCartStore(options) {
if (!isClient) {
return configureStore({
reducer,
preloadedState: { ...initialState, ...options }
})
}
let storage
if (isClient) storage = options.storage || createLocalStorage()
else storage = createNoopStorage()
delete options.storage
const persistConfig = {
key: 'root',
version: 1,
storage,
whitelist: ['cartCount', 'totalPrice', 'formattedTotalPrice', 'cartDetails']
}
const persistedReducer = persistReducer(persistConfig, reducer)
const newInitialState = { ...initialState, ...options }
updateFormattedTotalPrice(newInitialState)
return configureStore({
reducer: persistedReducer,
preloadedState: newInitialState,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
}
}).concat(handleStripe, handleWarnings)
})
}
Example #10
Source File: index.js From sorbet-finance with GNU General Public License v3.0 | 6 votes |
store = configureStore({
reducer: {
root,
multicall,
//application,
// user,
// transactions,
// swap,
// mint,
// burn,
// lists
},
middleware: [...getDefaultMiddleware(), save({ states: PERSISTED_KEYS })],
preloadedState: load({ states: PERSISTED_KEYS }),
})
Example #11
Source File: store.js From react-14.01 with MIT License | 6 votes |
initStore = (preloadedState = {}) => {
return configureStore({
reducer: persist,
middleware: [createLogger(), routerMiddleware(history), chatMiddleware, botMiddleware, UnreadMessageMiddleware, thunk],
preloadedState,
devTools: devTools,
})
}
Example #12
Source File: store.js From pointless with GNU General Public License v3.0 | 6 votes |
function configureAppStore() {
const store = configureStore({
reducer: {
paper: paperReducer,
settings: settingsReducer,
router: routerReducer,
library: libraryReducer,
},
middleware: [saveStateMiddleware, thunkMiddleware],
});
return store;
}
Example #13
Source File: index.js From tclone with MIT License | 6 votes |
store = configureStore({
reducer: {
posts: postsReducer,
search: searchReducer,
trends: trendsReducer,
users: usersReducer,
notify: notifyReducer,
auth: authReducer
},
middleware: [...getDefaultMiddleware({ immutableCheck: false })]
})
Example #14
Source File: index.js From oasis-wallet-ext with Apache License 2.0 | 6 votes |
applicationEntry = {
async run() {
this.createReduxStore();
this.appInit(this.reduxStore)
this.render();
},
async appInit(store) {
appOpenListener(store)
await getLocalStatus(store)
getLocalNetConfig(store)
},
createReduxStore() {
this.reduxStore = configureStore({
reducer: rootReducer,
middleware: [...getDefaultMiddleware(),
],
});
},
render() {
ReactDOM.render(
<React.StrictMode>
<Provider store={this.reduxStore}>
<App />
</Provider>
</React.StrictMode>,
document.getElementById("root")
);
},
}
Example #15
Source File: store.js From frontend-app-course-authoring with GNU Affero General Public License v3.0 | 6 votes |
export default function initializeStore(preloadedState = undefined) {
return configureStore({
reducer: {
courseDetail: courseDetailReducer,
discussions: discussionsReducer,
pagesAndResources: pagesAndResourcesReducer,
models: modelsReducer,
live: liveReducer,
},
preloadedState,
});
}
Example #16
Source File: store.js From frontend-app-discussions with GNU Affero General Public License v3.0 | 6 votes |
export function initializeStore(preloadedState = undefined) {
return configureStore({
reducer: {
topics: topicsReducer,
threads: threadsReducer,
comments: commentsReducer,
cohorts: cohortsReducer,
config: configReducer,
blocks: blocksReducer,
learners: learnersReducer,
},
preloadedState,
});
}
Example #17
Source File: store.js From frontend-app-library-authoring with GNU Affero General Public License v3.0 | 6 votes |
buildStore = (overrides = {}) => configureStore({
reducer: {
[STORE_NAMES.BLOCKS]: libraryBlockReducer,
[STORE_NAMES.AUTHORING]: libraryAuthoringReducer,
[STORE_NAMES.EDIT]: libraryEditReducer,
[STORE_NAMES.CREATE]: libraryCreateReducer,
[STORE_NAMES.COURSE_IMPORT]: courseImportReducer,
[STORE_NAMES.LIST]: libraryListReducer,
[STORE_NAMES.ACCESS]: libraryAccessReducer,
},
...overrides,
})
Example #18
Source File: configureStore.js From apollo-epoch with MIT License | 6 votes |
export default function () {
return configureStore({
reducer: rootReducer,
middleware: [
...getDefaultMiddleware(), // returns THUNK and compose w/ DevTools
logger,
initializePort,
],
});
}
Example #19
Source File: index.js From pine-interface with GNU General Public License v3.0 | 6 votes |
store = configureStore({
reducer: {
root,
multicall
//application,
// user,
// transactions,
// swap,
// mint,
// burn,
// lists
},
middleware: [...getDefaultMiddleware(), save({ states: PERSISTED_KEYS })],
preloadedState: load({ states: PERSISTED_KEYS })
})
Example #20
Source File: store.js From secure-electron-template with MIT License | 6 votes |
store = configureStore({
reducer: combineReducers({
router: routerReducer,
home: homeReducer,
undoable: undoable(
combineReducers({
counter: counterReducer,
complex: complexReducer
})
)
}),
middleware: [...getDefaultMiddleware({
serializableCheck: false
}), routerMiddleware]
})
Example #21
Source File: configureStore.js From rtk-demo with MIT License | 6 votes |
export default function configureAppStore(initialState = {}) {
const reduxSagaMonitorOptions = {};
const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
const { run: runSaga } = sagaMiddleware;
// sagaMiddleware: Makes redux-sagas work
const middlewares = [sagaMiddleware];
const enhancers = [
createInjectorsEnhancer({
createReducer,
runSaga,
}),
];
const store = configureStore({
reducer: createReducer(),
middleware: [...getDefaultMiddleware(), ...middlewares],
preloadedState: initialState,
devTools: process.env.NODE_ENV !== 'production',
enhancers,
});
// Make reducers hot reloadable, see http://mxs.is/googmo
/* istanbul ignore next */
if (module.hot) {
module.hot.accept('./reducers', () => {
forceReducerReload(store);
});
}
return store;
}
Example #22
Source File: store.js From genshin with MIT License | 5 votes |
store = configureStore({ reducer: rootReducer, })
Example #23
Source File: store.js From saasgear with MIT License | 5 votes |
store = configureStore({ reducer: rootReducer, })
Example #24
Source File: store.js From plenty-interface with GNU General Public License v3.0 | 5 votes |
store = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(analyticsQueries.middleware),
})
Example #25
Source File: index.js From auro-wallet-browser-extension with Apache License 2.0 | 5 votes |
applicationEntry = {
async run() {
this.createReduxStore();
await this.appInit(this.reduxStore)
this.render();
},
async appInit(store) {
extension.runtime.connect({ name: WALLET_CONNECT_TYPE.WALLET_APP_CONNECT });
// init netRequest
let netConfig = await getLocalNetConfig(store)
sendNetworkChangeMsg(netConfig.currentConfig)
// init nextRoute
let accountData = await getLocalStatus(store)
const {nextRoute} = accountData
// init Currency
getLocalCurrencyConfig(store)
if(nextRoute){
store.dispatch(updateEntryWitchRoute(nextRoute))
}
},
createReduxStore() {
this.reduxStore = configureStore({
reducer: rootReducer,
middleware: [...getDefaultMiddleware(),
],
});
},
render() {
ReactDOM.render(
<React.StrictMode>
<Provider store={this.reduxStore}>
<App />
</Provider>
</React.StrictMode>,
document.getElementById("root")
);
},
}
Example #26
Source File: index.js From network-rc with Apache License 2.0 | 5 votes |
store = configureStore({ reducer: { ui: uiReducer, }, })
Example #27
Source File: store.js From teach-yourself-code with MIT License | 5 votes |
initializeStore = () => {
return configureStore({
reducer,
});
}
Example #28
Source File: index.js From gsoc-organizations with GNU General Public License v3.0 | 5 votes |
store = configureStore({ reducer: { filters: filtersReducer, search: searchReducer, }, })
Example #29
Source File: store.js From social with The Unlicense | 5 votes |
store = configureStore({ reducer: rootReducer, middleware: customizedMiddleware, })