-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstate.js
40 lines (31 loc) · 882 Bytes
/
state.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
'use strict';
import React, {View} from 'react-native';
import {connect, Provider} from 'react-redux';
import * as reducers from './reducers';
import {createStore, applyMiddleware, combineReducers} from 'redux';
// lets us dispatch() functions
import thunkMiddleware from 'redux-thunk';
import createLogger from 'redux-logger'
let createStoreWithMiddleware = applyMiddleware(
thunkMiddleware,
createLogger()
)(createStore);
let INITIAL_STATE = {}; // TODO populate from persistent store.
let store = createStoreWithMiddleware(combineReducers(reducers), INITIAL_STATE);
function select(state) {
//filter to only expose parts of state
return state;
}
function Stateful(APP) {
APP = connect(select)( APP );
return React.createClass({
render() {
return (
<Provider store={store}>
<APP/>
</Provider>
);
}
});
}
export default Stateful