This repository has been archived by the owner on Jun 13, 2022. It is now read-only.
-
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.
Merge pull request #2 from Aku-mi/persist_storage
Persist Storage Added
- Loading branch information
Showing
7 changed files
with
86 additions
and
13 deletions.
There are no files selected for viewing
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,13 @@ | ||
import React from 'react'; | ||
import {Provider} from 'react-redux'; | ||
import {store} from './redux/store'; | ||
import {store, persistor} from './redux/store'; | ||
import {PersistGate} from 'redux-persist/integration/react'; | ||
import {Pages} from './pages'; | ||
|
||
export default () => ( | ||
<Provider store={store}> | ||
<Pages /> | ||
<PersistGate loading={null} persistor={persistor}> | ||
<Pages /> | ||
</PersistGate> | ||
</Provider> | ||
); |
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
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 {configureStore, combineReducers} from '@reduxjs/toolkit'; | ||
import themeReducer from './theme'; | ||
import userReducer from './user'; | ||
|
||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import { | ||
persistStore, | ||
persistReducer, | ||
FLUSH, | ||
PAUSE, | ||
PERSIST, | ||
PURGE, | ||
REGISTER, | ||
REHYDRATE, | ||
} from 'redux-persist'; | ||
|
||
const persistConfig = { | ||
key: 'root', | ||
storage: AsyncStorage, | ||
}; | ||
|
||
const rootReducer = combineReducers({ | ||
themeReducer: persistReducer(persistConfig, themeReducer), | ||
userReducer: persistReducer(persistConfig, userReducer), | ||
}); | ||
|
||
export const store = configureStore({ | ||
reducer: {themeReducer, userReducer}, | ||
reducer: rootReducer, | ||
middleware: getDefaultMiddleware => | ||
getDefaultMiddleware({ | ||
serializableCheck: { | ||
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], | ||
}, | ||
}), | ||
}); | ||
|
||
export const persistor = persistStore(store); | ||
|
||
export type RootState = ReturnType<typeof store.getState>; | ||
export type AppDispatch = typeof store.dispatch; |
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