1、 创建 store 文件,关联 reducer
import { createStore } from 'redux';
import MainReducer from '../reducers';
let store = createStore(MainReducer);
export default store;
2、 在项目根目录引入 store
import {Provider}from 'react-redux';
import store from './Redux/Store'
class RootComponent extends Component {
constructor() {
super();
this.router = new RouterUtil();
this.state = {store: store};
}
render() {
let component =
this.router.route(this.props.component);
return (
<Provider store={this.state.store}>
<Navigation initialRoute={{component:
component}}/>
</Provider>
);
}
}
评论1
最新资源