Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import Router from './src/navigator/Main/MainRouter';
- import ReduxThunk from 'redux-thunk';
- import { Provider } from 'react-redux';
- import { compose, createStore, applyMiddleware } from 'redux';
- import { persistStore, persistReducer } from 'redux-persist';
- import storage from 'redux-persist/lib/storage';
- import { PersistGate } from 'redux-persist/integration/react'
- import reducers from './src/reducers'; // my reducer
- // React Native Debugger2 setting
- const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
- // redux-persist setting
- const persistConfig = {
- key: 'root',
- storage,
- whitelist: ['device_id']
- };
- const persistedReducer = persistReducer(persistConfig, reducers);
- export default class App extends Component {
- render() {
- const store = createStore(persistedReducer, {}, composeEnhancers(applyMiddleware(ReduxThunk)));
- const persistor = persistStore(store);
- if (!__DEV__) {
- console.log = () => {};
- }
- return (
- <Provider store={store}>
- <PersistGate loading={null} persistor={persistor}>
- <Router />
- </PersistGate>
- </Provider>
- );
- }
- }
Add Comment
Please, Sign In to add comment