@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 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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
Source File: store.js From saasgear with MIT License | 5 votes |
store = configureStore({ reducer: rootReducer, })
Example #23
Source File: store.js From notence with MIT License | 5 votes |
store = configureStore({ reducer: persistedReducer, preloadedState: demoState, })
Example #24
Source File: index.jsx From ResoBin with MIT License | 5 votes |
store = configureStore({
reducer: persistedReducer,
devTools: process.env.NODE_ENV === 'development',
middleware,
preloadedState: {},
})
Example #25
Source File: index.js From discovery-mobile-ui with MIT License | 5 votes |
createStore = (authentication) => {
const { baseUrl, tokenResponse: { accessToken, idToken } } = authentication;
const fhirClient = new FhirClient(baseUrl, accessToken, idToken);
const epicMiddleware = createEpicMiddleware({
dependencies: {
fhirClient,
},
});
const { patientId } = fhirClient;
const rootReducer = combineReducers({
resources: flattenedResourcesReducer,
associations: associationsReducer,
activeCollectionId: activeCollectionIdReducer,
collections: collectionsReducer,
creatingCollection: isCreatingNewCollectionReducer,
});
const persistReducerConfig = {
version: '0.1.0',
key: `root-${patientId}`,
storage: AsyncStorage,
whitelist: ['activeCollectionId', 'collections', 'creatingCollection'],
};
const store = configureStore({
reducer: persistReducer(persistReducerConfig, rootReducer),
middleware: compose([
thunk,
epicMiddleware,
// routerMiddleware(history), // < e.g.: other middleware
]),
devTools: {
serialize: true, // See: https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize
},
});
epicMiddleware.run(rootEpic);
const callback = () => {
// callback function will be called after rehydration is finished.
};
const persistConfig = {
// manualPersist: true,
};
const persistor = persistStore(store, persistConfig, callback);
return {
store,
persistor,
};
}
Example #26
Source File: index.js From dashboard-for-socialmedia-trend with MIT License | 5 votes |
store = configureStore({ reducer: rootReducer })
Example #27
Source File: index.js From fokus with GNU General Public License v3.0 | 5 votes |
store = configureStore({ reducer: { tasks: tasksReducer, settings: settingsReducer, notes: notesReducer, }, preloadedState: getStateFromLocalStorage(), })
Example #28
Source File: store.js From os-league-tools with MIT License | 5 votes |
store = configureStore({ reducer, preloadedState, middleware: [thunk], })
Example #29
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),
})