Skip to content

The setState furnction from useState should be in the dependency array when called from within useEffect #4506

@ellertsmari

Description

@ellertsmari

As talked about here and explained in this article. The setState function from the useState hook should be in the dependency array when it is called from useEffect. This is not done in the documentation. The clearest example is probably from the hooks-faq where this example is given:

image

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