I'm trying to create new reducer survey
, which must combine name
and questions
reducers while using handleActions
from redux-actions
package. But I recieve an error Invariant Violation: Expected handlers to be a plain object.
How should I change it to actually work?
import { Map, List } from 'immutable';
import { combineReducers } from 'redux-immutable';
import { handleActions } from 'redux-actions';
const initialNameState = List();
const initialQuestionsState = List();
const name = handleActions({}, initialNameState);
const questions = handleActions({}, initialQuestionsState);
export const initialSurveyState = Map({
name: initialNameState,
questions: initialQuestionsState
});
export const survey = handleActions(
combineReducers({
name,
questions
}),
initialSurveyState
);
handleAction
actually creates a reducer. Directly using combineReducer
should solve the problem.
import React, { Component } from 'react';
import { render } from 'react-dom';
import { createStore, combineReducers } from 'redux';
import { connect, Provider } from 'react-redux';
import { Map, List } from 'immutable';
import { combineReducers } from 'redux-immutable';
import { handleActions, createAction, combineActions } from 'redux-actions';
const initialNameState = List();
const initialQuestionsState = List();
const name = handleActions({}, initialNameState);
const questions = handleActions({}, initialQuestionsState);
export const survey = combineReducers({name, questions});
const store = createStore(survey);