react-navigation-is-focused-hoc icon indicating copy to clipboard operation
react-navigation-is-focused-hoc copied to clipboard

how to integrate it with Provider & PersistGate

Open alainib opened this issue 7 years ago • 0 comments

Steps to reproduce

this is my actual code :

store.js

import { createStore, compose, applyMiddleware } from 'redux';
import { persistStore, persistCombineReducers } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import { createLogger } from 'redux-logger';
import rootReducers from "test/src/redux/reducers";

const config = {
  key: 'root',
  storage,
};
const middleware = [];

const reducers = persistCombineReducers(config, rootReducers);
const enhancers = [applyMiddleware(...middleware)];
const initialState = {};
const persistConfig = { enhancers };
const store = createStore(reducers, undefined, compose(...enhancers));
const persistor = persistStore(store, persistConfig, () => {});
const configureStore = () => {
  return { persistor, store };
}

export default configureStore;

App.js

import configureStore from "test/src/redux/store";
const { persistor, store } = configureStore();

const MyTabView = TabNavigator({ ... });

export default class App extends React.PureComponent {
 ...	
 render() {
	return (
	  <Provider store={store}>
		<PersistGate
		  loading={<ActivityIndicator />}
		  persistor={persistor}>
			<MyTabView />          
		</PersistGate>
	  </Provider>
	);
  }
}

Expected behaviour

how to integrate your lib with Provider and PersistGate instead of AppNavigator

Environment

  • react: "^16.3.0-alpha.1",
  • react-native: "0.54.2",
  • React Native platform + platform version**: iOS and Android

react-navigation-is-focused-hoc

Version: npm version or "master"

alainib avatar Apr 04 '18 07:04 alainib