generated from Sokilskill/goit-react-hw-04-phonebook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0930375
commit fc476d8
Showing
6 changed files
with
64 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import { PersistGate } from 'redux-persist/integration/react'; | ||
import { Provider } from 'react-redux'; | ||
import { store } from 'redux/store'; | ||
import store, { persistor } from 'redux/store'; | ||
import { App } from 'components/App'; | ||
import './index.css'; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')).render( | ||
<React.StrictMode> | ||
<Provider store={store}> | ||
<App /> | ||
<PersistGate loading={null} persistor={persistor}> | ||
<App /> | ||
</PersistGate> | ||
</Provider> | ||
</React.StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,40 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import { combineReducers, configureStore } from '@reduxjs/toolkit'; | ||
import contactsSliceReducer from './contacts/contactsSlice'; | ||
import filterSliceReducer from './filterSlice.js/filterSlice'; | ||
import { | ||
persistStore, | ||
persistReducer, | ||
FLUSH, | ||
REHYDRATE, | ||
PAUSE, | ||
PERSIST, | ||
PURGE, | ||
REGISTER, | ||
} from 'redux-persist'; | ||
import storage from 'redux-persist/lib/storage'; | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
contacts: contactsSliceReducer, | ||
filter: filterSliceReducer, | ||
}, | ||
const persistConfig = { | ||
key: 'root', | ||
storage, | ||
whitelist: ['contacts'], | ||
}; | ||
|
||
const rootReducer = combineReducers({ | ||
contacts: contactsSliceReducer, | ||
filter: filterSliceReducer, | ||
}); | ||
|
||
const persistedReducer = persistReducer(persistConfig, rootReducer); | ||
|
||
const store = configureStore({ | ||
reducer: persistedReducer, | ||
middleware: getDefaultMiddleware => | ||
getDefaultMiddleware({ | ||
serializableCheck: { | ||
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], | ||
}, | ||
}), | ||
}); | ||
|
||
export const persistor = persistStore(store); | ||
export default store; |