Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: Warning: Cannot update a component (DevTool) while rendering a different component. #208

Open
1 task done
yudielcurbelo opened this issue Apr 16, 2024 · 3 comments

Comments

@yudielcurbelo
Copy link

Version Number

7.51.3

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/nervous-nova-mjw92s?file=%2Fsrc%2FApp.tsx

Steps to reproduce

  1. Go to Sandbox
  2. See console

Expected behaviour

This warning is not present on 7.51.0 but is in 7.51.1 and current.

There should not be any warning.

uh1Tz87m7M

What browsers are you seeing the problem on?

Chrome

Relevant log output

Warning: Cannot update a component (`DevTool`) while rendering a different component (`Unknown`). To locate the bad setState() call inside `Unknown`, follow the stack trace as described in https://fb.me/setstate-in-render
    in Unknown (at App.tsx:47)
    in form (at App.tsx:40)
    in div (at App.tsx:34)
    in App (at src/index.tsx:7)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@cmayoracurzio
Copy link

Thank you @yudielcurbelo for opening this issue. Also adding link to original issue which was incorrectly transferred to the devtools repo.

@bluebill1049 bluebill1049 transferred this issue from react-hook-form/react-hook-form Apr 16, 2024
@Bartizan
Copy link

Here is a sample of the same error with data binding via values property.

The source code: react-hook-form-devtool-issue.zip
react-hook-form: 7.51.1 - 7.51.3
@hookform/devtools: 4.3.1

function App() {
  const { control, register, handleSubmit } = useForm({
    values: { firstName: 'John' }   // <-- causes error "Cannot update a component (`DevTool`) while rendering a different component (`Controller`)."
  });

  const onSubmit = (data: unknown) => {
    alert(JSON.stringify(data));
  };

  return (<>
    <form onSubmit={handleSubmit(onSubmit)}>
      <div>
        <label htmlFor="firstName">First Name</label>
        <input placeholder="first name" {...register("firstName")} />
      </div>

      <input type="submit" />
    </form>

    <DevTool control={control} />
  </>);
}

@dd-jonas
Copy link

dd-jonas commented May 7, 2024

Also facing this issue, had to remove devtools from my forms 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants