-
Notifications
You must be signed in to change notification settings - Fork 2
/
Root.js
51 lines (44 loc) · 1.19 KB
/
Root.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as React from "react";
import {
SafeAreaView,
View,
StyleSheet
} from "react-native";
import { createStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import logger from "redux-logger";
import { PersistGate } from "redux-persist/integration/react";
import AsyncStorage from "@react-native-community/async-storage";
import appReducers from "./src/reducers";
import App from "./src/components/App";
const Provider = require("react-redux").Provider;
const { persistStore, persistReducer } = require("redux-persist");
const createStoreWithMiddleware = applyMiddleware(thunk, logger)(createStore);
const persistConfig = {
key: "root",
storage: AsyncStorage,
};
const persistedReducer = persistReducer(persistConfig, appReducers);
const store = createStoreWithMiddleware(persistedReducer);
const persistor = persistStore(store);
const Root = () => {
return (
<Provider store={store}>
<PersistGate
loading={<View />}
onBeforeLift={null}
persistor={persistor}
>
<SafeAreaView style={styles.container}>
<App />
</SafeAreaView>
</PersistGate>
</Provider>
);
};
export default Root;
const styles = StyleSheet.create({
container: {
flex: 1
}
});