-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.js
More file actions
86 lines (66 loc) · 2.15 KB
/
Copy pathApp.js
File metadata and controls
86 lines (66 loc) · 2.15 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
'use strict';
import React, { Component } from 'react'
import {
AppRegistry
} from 'react-native'
import { Router, Scene, Actions } from 'react-native-router-flux'
import configureStore from './src/store/configureStore'
import { bindActionCreators } from 'redux'
import * as ProfileActions from './src/actions/profile'
import * as AuthActions from './src/actions/auth'
import { Provider, connect } from 'react-redux'
import Splash from './src/components/Splash'
import Login from './src/components/Login'
import Home from './src/components/Home'
export const store = configureStore()
// map Redux state and actions to component props
function mapStateToProps(state) {
return {
bio: state.profile.bio,
currentUser: state.auth.currentUser
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({ ...AuthActions, ...ProfileActions }, dispatch)
}
const ConnectedRouter = connect(mapStateToProps, mapDispatchToProps)(Router);
// each scene needs to be connected manually to the states/actions they need access to
// put this in their respective files if you prefer
const ConnectedSplash = connect(mapStateToProps, mapDispatchToProps)(Splash);
const ConnectedHome = connect(mapStateToProps, mapDispatchToProps)(Home);
const ConnectedLogin = connect(mapStateToProps, mapDispatchToProps)(Login);
// Create scenes once to prevent them being re-created for each render of your Router
const scenes = Actions.create(
<Scene key='root'>
<Scene
key="splash"
component={ConnectedSplash}
title="Loading"
hideNavBar={true}
/>
<Scene
key="home"
component={ConnectedHome}
title="Home"
/>
<Scene
key="login"
component={ConnectedLogin}
title="Log In"
/>
</Scene>
)
export default class RNFacebookFirebase extends Component {
constructor(props){
super(props);
}
render() {
return(
// create router connected to Redux
<Provider store={store}>
<ConnectedRouter scenes={scenes} />
</Provider>
)
}
}
AppRegistry.registerComponent('RNFacebookFirebase', () => RNFacebookFirebase);