Skip to content

Infinite onWillUpdateProps Loop Triggered by Setting State to NaN via useSubEnv Callback #1688

@kig-odoo

Description

@kig-odoo

Components Involved

  • Root (parent component)
  • ChildComponent

Summary

In my setup:

  • The Root component manages state and passes the noProxy object as props to the ChildComponent, derived from its state.
  • Additionally, Root provides a callback function (notifyParentComponent) to ChildComponent using useSubEnv, so that the child can trigger updates in the parent.

The issue arises when notifyParentComponent sets NaN to any of the Root’s state keys (note: this key is not part of the props passed to ChildComponent). Once this happens, the onWillUpdateProps lifecycle method starts getting called in an infinite loop.

Playgroud

Click the button in this example to observe the issue:
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