Guest User

Untitled

a guest
Feb 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import Router from './src/navigator/Main/MainRouter';
  3. import ReduxThunk from 'redux-thunk';
  4. import { Provider } from 'react-redux';
  5. import { compose, createStore, applyMiddleware } from 'redux';
  6. import { persistStore, persistReducer } from 'redux-persist';
  7. import storage from 'redux-persist/lib/storage';
  8. import { PersistGate } from 'redux-persist/integration/react'
  9. import reducers from './src/reducers'; // my reducer
  10.  
  11. // React Native Debugger2 setting
  12. const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
  13.  
  14. // redux-persist setting
  15. const persistConfig = {
  16. key: 'root',
  17. storage,
  18. whitelist: ['device_id']
  19. };
  20.  
  21. const persistedReducer = persistReducer(persistConfig, reducers);
  22.  
  23.  
  24. export default class App extends Component {
  25. render() {
  26. const store = createStore(persistedReducer, {}, composeEnhancers(applyMiddleware(ReduxThunk)));
  27. const persistor = persistStore(store);
  28. if (!__DEV__) {
  29. console.log = () => {};
  30. }
  31.  
  32. return (
  33. <Provider store={store}>
  34. <PersistGate loading={null} persistor={persistor}>
  35. <Router />
  36. </PersistGate>
  37. </Provider>
  38. );
  39. }
  40. }
Add Comment
Please, Sign In to add comment