Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docs: Clarify the behavior of useEffect with non-primitive dependencies in the Hooks documentation #8156

Open
@jagadeeshkaruturi11

Description

Issue Body (Example):
🗣 Area of Concern: The documentation section for the useEffect hook currently explains the dependency array primarily using primitive values (e.g., numbers, strings). However, the common pitfall of including non-primitive values (objects or arrays) directly in the dependency array (which causes the effect to run on every render due to reference change) is not explicitly highlighted or given a clear warning/solution.

📝 Proposed Solution/Enhancement:

Add a small section or a highlighted "Note on Non-Primitives" to the useEffect page.

Provide a code example demonstrating the infinite loop/excessive-rerender issue when using an object literal ({}) or array literal ([]) inside the dependency array.

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

        AltStyle によって変換されたページ (->オリジナル) /