MCPcopy Index your code
hub / github.com/freeCodeCamp/freeCodeCamp / createStore

Function createStore

client/src/redux/create-store.ts:20–61  ·  view source on GitHub ↗
(preloadedState = {})

Source from the content-addressed store, hash-verified

18};
19
20export const createStore = (preloadedState = {}) => {
21 const clientSide = isBrowser();
22 const sagaMiddleware = createSagaMiddleware({
23 context: {
24 document: clientSide ? document : {}
25 }
26 });
27 const epicMiddleware = createEpicMiddleware({
28 dependencies: {
29 window: clientSide ? window : {},
30 location: clientSide ? window.location : {},
31 document: clientSide ? document : {}
32 }
33 });
34
35 const store = configureStore({
36 // @ts-expect-error RTK uses unknown, Redux uses any
37 reducer: rootReducer,
38 // @ts-expect-error RTK uses unknown, Redux uses any
39 middleware: getDefaultMiddleware => {
40 return getDefaultMiddleware()
41 .concat(examAttempts.middleware)
42 .concat(examEnvironmentAuthorizationTokenApi.middleware)
43 .concat(sagaMiddleware)
44 .concat(epicMiddleware);
45 },
46 preloadedState
47 });
48 sagaMiddleware.run(rootSaga);
49 epicMiddleware.run(rootEpic);
50
51 if (module.hot) {
52 // Enable Webpack hot module replacement for reducers
53 module.hot.accept('./root-reducer', () => {
54 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports
55 const nextRootReducer = require('./root-reducer');
56 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
57 store.replaceReducer(nextRootReducer);
58 });
59 }
60 return store;
61};

Callers 15

gatsby-browser.tsxFile · 0.90
gatsby-ssr.tsxFile · 0.90
renderWithReduxFunction · 0.90
time-line.test.tsxFile · 0.90
makeStoreFunction · 0.90
renderWithReduxFunction · 0.90
renderWithReduxFunction · 0.90
renderWithStoreFunction · 0.90
createTestStoreFunction · 0.90

Calls 1

isBrowserFunction · 0.90

Tested by 11

renderWithReduxFunction · 0.72
makeStoreFunction · 0.72
renderWithReduxFunction · 0.72
renderWithReduxFunction · 0.72
renderWithStoreFunction · 0.72
createTestStoreFunction · 0.72
renderArchiveFunction · 0.72
renderCompletionModalFunction · 0.72
renderActionRowFunction · 0.72
renderShowExamFunction · 0.72
renderWithUserFunction · 0.68