Skip to content

Error when handleActions' map doesn't contain entries #173

@ruszki

Description

@ruszki

Hi,

When an empty map is passed to handleActions, then Redux is failed because undefined will be returned for undefined state input. This has been already indicated in the discussion of #167 by @geminiyellow. The error message:

Uncaught Error: Reducer "somekeyinsomestateobject" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.

The message comes from Redux, but the problem is caused by implementation of redux-actions' handleActions.

Of course there are not many useful use-cases for an empty map. Reducers of such handleActions basically mean that their associated state elements are unmodifiable, which is not recommended, as far as I know. It can be a "feature", but then the documentation should be updated indicating this mandatory condition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions