Skip to content

Documentation for this.state mutation seems contradictory #7108

Closed
@mitchabaza

Description

@mitchabaza

In the documentation for the component API , it says:

NEVER mutate this.state directly, as calling setState() afterwards may replace the mutation you made. Treat this.state as if it were immutable.

However, the documentation for ES6 Classes says:

The API is similar to React.createClass with the exception of getInitialState. Instead of providing a separate getInitialState method, you [can mutate] this.state in the constructor.

Perhaps it would be possible to make this exception to this.state mutation more clear?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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