Skip to main content

Store

Content

The store is defined together with redux-persist (read next about it) as reducer and disables serializableCheck of middlewares:

const store = configureStore({
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: false,
}),
});

Middlewares

This template utilizes middlewares what come together with the toolkit with addition of redux-persist to have data stored for offline usage.

Redux-persist

Check it out how it works.

It's defined in src/core/store.ts near the store:

const persistConfig: PersistConfig<RootState> = {
key: 'root',
storage: reduxStorage,
version: 1,
timeout: 1000,
};

It uses react-native-mmkv as storage, if you don't like it you can change it to your own likings.

It creates persistor:

const persistor = persistStore(store);

Which is being used in PersistGate of reduxProvider wrapper:

export const reduxProvider = (Component: any) => (props: any) => {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Component {...props} />
</PersistGate>
</Provider>
);
};