Skip to content

Forbid getState() and subscribe() while the reducer is being called #1568

Closed
@gaearon

Description

@gaearon

This is an anti-pattern, first found here: reduxjs/redux-devtools#264.

I think we should protect against store.getState() calls from inside the reducer. They make the reducer impure, and you can always pass the store state down as the third argument if this is something you’re interested in.

I think we should forbid this pattern just like we forbid dispatch() while the reducer is running.

Same goes for subscribe() which should never be called from inside a reducer.

A pull request to implement this is welcome.

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