-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
50 lines (44 loc) · 1.32 KB
/
index.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
import React from 'react'
import { AppRegistry } from 'react-native'
import { Provider } from 'react-redux'
import { PersistGate } from 'redux-persist/es/integration/react'
import AppRedux from './AppRedux'
import AppRedux1 from './AppRedux1'
import AppRedux2 from './AppRedux2'
import AppRedux3 from './AppRedux3' // 比较复杂的RN界面
import configureStore from './src/redux/store'
// import RnToast from './src/module/RnToast'
const { persistor, store } = configureStore()
const ReduxApp = bundle => {
var _key = bundle.routerType
// RnToast.show('=====' + _key, RnToast.LONG)
if (_key === '1') {
return (
// 配置 Provider 为根组件,同时传入 store 作为其属性
<Provider store={store}>
{/* redux 持久化存储 */}
<PersistGate persistor={persistor}>
<AppRedux1 />
</PersistGate>
</Provider>
)
} else if (_key === '2') {
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
<AppRedux2 />
</PersistGate>
</Provider>
)
} else if (_key === '3') {
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
<AppRedux3 />
</PersistGate>
</Provider>
)
}
return <AppRedux />
}
AppRegistry.registerComponent('RNLearning', () => ReduxApp)