を使用している場合ので、私は減速していaction.typeからの減速を指定します。ReduxのはcombineReducer
const buttonReducer = (state = { buttons: [] }, action) => {
switch(action.type)
{
case "add":
{
state = { ...state, buttons: [...state.buttons, action.payload] }
break;
}
case "minus":
{
state = { buttons : state.buttons.filter(item => item !== action.payload) }
break;
}
default:
break;
}
return state;
};
は今、私は別の減速機を持っていると言うのだけで、これに似ている(我々はそれcomponentReducerを呼ぶことにします)ケースのコードが変更されました。今私はcombinedReducersをした後にどの減速器に行くべきかを指定するにはどうすればいいですか?
const reducers = combineReducers({
component: componentReducer,
button: buttonReducer
});
store.component.dispatch(...)
は動作しますか?それとも単にケースの名前を変更するだけですか?
接続:
const Search = connect(
(store) =>
{
return { number: store.component.number};
}) (SearchComponent);
コンポーネントを店舗に接続するのに 'react-redux'を使用していますか? – Chris
はい、すでに接続されています。私は自分の接続がどのように見えるかを更新します。 –