2017-07-04 13:14:01 +00:00
|
|
|
import React from 'react'
|
|
|
|
import {createStore, applyMiddleware} from 'redux'
|
|
|
|
import reducers from './reducers'
|
|
|
|
import {Provider, connect} from 'react-redux'
|
|
|
|
import thunk from 'redux-thunk'
|
|
|
|
import {View, Text} from 'react-native'
|
|
|
|
import {SetDev, getStoreList} from './actions'
|
|
|
|
|
|
|
|
// import pages
|
|
|
|
import StoreList from './containers/StoreList'
|
2017-07-04 15:08:19 +00:00
|
|
|
import ItemsPage from './containers/ItemsPage'
|
2017-07-04 13:14:01 +00:00
|
|
|
|
|
|
|
const middleware = [thunk]
|
|
|
|
|
|
|
|
const store = createStore(reducers, applyMiddleware(...middleware))
|
|
|
|
|
|
|
|
store.subscribe(() => {
|
|
|
|
console.log(JSON.stringify(store.getState()))
|
|
|
|
})
|
|
|
|
|
2017-07-04 15:08:19 +00:00
|
|
|
const VV = (props) => {
|
|
|
|
console.log(props)
|
|
|
|
return (
|
|
|
|
<View style={{flex: 1}}>
|
|
|
|
{
|
|
|
|
props.children
|
|
|
|
}
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const CView = connect()(VV)
|
|
|
|
|
2017-07-04 13:14:01 +00:00
|
|
|
class Main extends React.Component {
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
let {dev} = this.props
|
|
|
|
store.dispatch(SetDev(dev))
|
|
|
|
store.dispatch(getStoreList())
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Provider store={store}>
|
2017-07-04 15:08:19 +00:00
|
|
|
<CView>
|
|
|
|
<StoreList />
|
|
|
|
<ItemsPage />
|
|
|
|
</CView>
|
2017-07-04 13:14:01 +00:00
|
|
|
</Provider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default Main
|