Skip to content

issue: wrapping form in useMemo stops field.onChange from working #12634

@jtomaszewski

Description

@jtomaszewski

Version Number

7.54.2

Codesandbox/Expo snack

https://codesandbox.io/p/devbox/festive-wind-7zs3h7

Steps to reproduce

The bug can't be reproduced on a development build. You need to make a production build to see the bug.

  1. Download code from https://codesandbox.io/p/devbox/festive-wind-7zs3h7
  2. Run npm install && npm run build && serve -s build
  3. Try changing fields in the first form (that uses React.useMemo under the hood). Notice that first input doesn't react to any keystrokes, and changing value of the second input doesn't update form values neither.

The second form (that doesn't use React.useMemo) works correctly.

Screen.Recording.2025-02-26.at.12.50.52.mov

Expected behaviour

Wrapping form or control in useMemo shouldn't prevent the form from responding to control.field.onChange calls.

So that one can pass the form and control objects downwards through react context, and benefit from useMemo and memo React functions.

Right now it's one of the other. If I use react-hook-form, I can't wrap some of my components with memo.

What browsers are you seeing the problem on?

Chrome

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions