Skip to content

Documentation should state that React preserves setState callback this context #8314

@AmirhossseinBabaei

Description

@AmirhossseinBabaei

I just recently found out that setState's callback calls with the correct this context per this line in the React source. Nowhere in the documentation is it stated that React internally calls callbacks with context. This should be made clear as many assume it doesn't, leading to unnecessary measures such as arrow functions, explicit binding, etc.

The lack of explicit documentation also creates confusion with other things that do require binding, such as traditional class methods used as event handlers.

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