-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
51 lines (43 loc) · 1.39 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
51
/**
* ChuckNorrisViewer
* https://github.com/tomoima525/ChuckNorrisViewer
* @flow
*/
import React,{Component} from 'react';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
import PropTypes from 'prop-types';
import {createEpicMiddleware} from 'redux-observable';
import { composeWithDevTools } from 'remote-redux-devtools';
import chuckNorris from './js/reducers';
import chuckEpic from './js/epics';
import App from './js/App';
import {AppRegistry} from 'react-native';
const composeEnhancers = composeWithDevTools({ realtime: true, port: 8000 });
const epicMiddleware = createEpicMiddleware(chuckEpic);
const store = createStore(chuckNorris, composeEnhancers(applyMiddleware(epicMiddleware)));
export default class ChuckNorrisViewer extends Component {
// Called from App. Child View Component can get values from here.
getChildContext() {
const { initialScene, data } = this.props;
if (data && typeof (data) === 'object') {
return { data, initialScene };
}
return { initialScene }; // No data
}
render() {
return (
<Provider store={store}>
<App/>
</Provider>
);
}
}
ChuckNorrisViewer.childContextTypes = {
data: PropTypes.oneOfType([
PropTypes.shape({ }),
PropTypes.string,
]),
initialScene: PropTypes.string,
};
AppRegistry.registerComponent('ChuckNorrisViewer', () => ChuckNorrisViewer);