Skip to content

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

Open

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.

Activity

  1. Assamee commented on Apr 17, 2026

    @Assamee

    I've submitted a PR (#8414) for this. I verified the behaviour in a local environment and confirmed you're right, this context is preserved without any manual binding. Good catch on the confusion with event handlers, it's definitely worth clarifying.

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