-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.ts
39 lines (33 loc) · 1.18 KB
/
store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { StrictMode } from 'react';
import { render } from 'react-dom';
import { BrowserRouter as Router } from 'react-router-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware, Action, Middleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import createSagaMiddleware, { SagaMiddleware } from 'redux-saga';
import App from './App';
import rootReducer from './reducers'; // Import the root reducer
const sagaMiddleware: SagaMiddleware<object> = createSagaMiddleware();
const configureStore = (initialState: RootState, configuration: any) => {
const store = createStore(
rootReducer, // Use the root reducer here
initialState,
composeWithDevTools(applyMiddleware(sagaMiddleware as Middleware))
);
sagaMiddleware.run(rootSaga);
return store;
};
const RootComponent = ({ store }: { store: any }) => (
<StrictMode>
<Provider store={store}>
<Router>
<App />
</Router>
</Provider>
</StrictMode>
);
const renderApp = () => {
const store = configureStore(initialState, configuration);
render(<RootComponent store={store} />, document.getElementById('root'));
};
renderApp();