0
:還元剤を入れ子状態のプロパティに割り当てますか?下記の反応/ Reduxのセットアップを
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import App from './components/app';
import configureStore from './store';
let initialState = {
foods: {
apple: {
selected: false,
flavors: {
sweet: true,
salty: false
}
},
potatoChips: {
selected: false,
flavors: {
sweet: false,
salty: true
}
}
},
drinks: {
< some other object >
}
}
let store = configureStore(initialState);
render(
<Provider store={store}>
<App/>
</Provider>,
document.getElementById('app')
)
store.js
import { applyMiddleware, compose, createStore } from 'redux';
import rootReducer from './root-reducer';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
let finalCreateStore = compose(
applyMiddleware(thunk, logger())
)(createStore)
let defInitialState = < same object as initialState above >
export default function configureStore(initialState = defInitialState){
return finalCreateStore(rootReducer, initialState)
}
ルートreducer.js
import { combineReducers } from 'redux';
import appleReducer from './apple-reducer';
import potatoChipsReducer from './potato-chips-reducer';
const rootReducer = combineReducers({
foods.apple: appleReducer,
foods['potatoChips']: potatoChipsReducer
// HOW DO I DO THE ABOVE ASSIGNMENT?
})
export default rootReducer
index.jsは私が割り当てることはでき私がやっているようにstate.foods.apple
への還元人上記の3210?それとも別のやり方でこれをやりますか?
はあなたが巣combineReducers
でき
ありがとうございました!私が探していたもの – lsimmons