使用 Redux-store 时,为 <Provider store="" > 中的 "store" 属性提供什么?
What to provide for "store" attribute in <Provider store="" > while working with Redux-store?
根组件需要包裹在里面,
<Provider store= >
<App />
</Provider>
但是,我不确定在商店属性中提供什么。谁能告诉我这个?
我一般都是这样存放所有reducer的。
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;
根组件需要包裹在里面,
<Provider store= >
<App />
</Provider>
但是,我不确定在商店属性中提供什么。谁能告诉我这个?
我一般都是这样存放所有reducer的。
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;