根组件需要包含在内部,如
<Provider store= >
<App />
</Provider>
但是,我不确定在store属性中提供什么。有人能让我知道吗?
答案 0 :(得分:1)
我通常用它来存储这样的所有减速器。
<强> index.js 强>
import { Provider, connect } from 'react-redux';
import ReduxThunk from 'redux-thunk';
import { createStore, applyMiddleware } from 'redux';
import reducers from './reducers';
const createStoreWithMiddleware = applyMiddleware(ReduxThunk)(createStore);
const store = createStoreWithMiddleware(reducers);
<Provider store={store}>
{/*routers here*/}
</Provider>
<强> reducers.js 强>
import { combineReducers } from 'redux-immutable';
// reducers import
import MainReducer from './containers/Main/reducer';
import RegisterReducer from './containers/Register/reducer';
import ChangePasswordReducer from './containers/ChangePassword/reducer';
const reducers = combineReducers({
main: MainReducer,
register: RegisterReducer,
changePassword: ChangePasswordReducer
})
export default reducers;