-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.js
More file actions
executable file
·70 lines (61 loc) · 1.86 KB
/
App.js
File metadata and controls
executable file
·70 lines (61 loc) · 1.86 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
/* global window */
import React, { Component } from 'react';
import { addNavigationHelpers } from 'react-navigation';
import { Provider, connect } from 'react-redux';
import { createStore, applyMiddleware, compose } from 'redux';
import firebase from 'firebase';
import ReduxThunk from 'redux-thunk'; // middleware
import { GOOGLE_FIREBASE_API_KEY } from './apis';
import reducers from './src/reducers'; // getting combined reducers
import { RootNavigator } from './src/Router';
import NavigatorService from './src/Navigator';
// --------------- Navigation --------------
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const navReducer = (state, action) => {
const newState = RootNavigator.router.getStateForAction(action, state);
return newState || state;
};
class AppNavigationWithState extends Component {
render() {
return (
<RootNavigator
ref={navigatorRef => {
NavigatorService.setContainer(navigatorRef);
}}
navigation={addNavigationHelpers({
dispatch: this.props.dispatch,
state: this.props.nav,
})} />
);
}
}
const store = createStore(
reducers(navReducer),
/* preloadedState, */
composeEnhancers(
applyMiddleware(ReduxThunk),
),
);
const mapStateToProps = state => ({nav: state.nav})
const Wrapped = connect(mapStateToProps)(AppNavigationWithState);
class App extends Component {
componentWillMount() {
const config = {
apiKey: GOOGLE_FIREBASE_API_KEY,
authDomain: 'manager-c381e.firebaseapp.com',
databaseURL: 'https://manager-c381e.firebaseio.com',
projectId: 'manager-c381e',
storageBucket: '',
messagingSenderId: '372117802073',
};
firebase.initializeApp(config);
}
render() {
return (
<Provider store={store}>
<Wrapped />
</Provider>
);
}
}
export default App;