1

Root component need to be wrapped inside like,

<Provider store= >
   <App />
</Provider>

But, I am not sure about what to provide in store attribute. Could anybody let me know this?

4

1 回答 1

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>

减速器.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;
于 2017-08-09T06:57:43.280 回答