Reputation: 13
This is the code in index file
i try to copy past a valid code but it doesnt work Please if anyone has the same probléme can help me
Upvotes: -1
Views: 158
Reputation: 28
I hope this helps... it's working example which i showed you . Just you remove persist config instead use thunk which you are using i guess.
index.js
import {store } from './Redux/Store';
import { Provider } from 'react-redux';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<Provider store={store} ><App/></Provider>
);
and in Store.js
import { legacy_createStore as createStore } from "redux";
import { userReducer } from "./user/userReducer.js";
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
const persistConfig = {
key: 'userReducer',
storage: storage,
};
const pReducer = persistReducer(persistConfig, userReducer);
const store = createStore(pReducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
const persistor = persistStore(store);
export {persistor,store}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
Upvotes: -1