Skip to content

Why are we putting function into component state? #899

@trungdq88

Description

@trungdq88

I'm trying to convince a friend of mine that he should only put serializable data types into React component state, then he gave me this link with an example of how Facebook add a function into component's state: https://reactjs.org/docs/context.html

This is the snippet:
context_-_react

Can someone help me to understand why we have to do this in the example code? Isn't it an anti-pattern?

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