question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useFormContext is triggering updates in useEffect

See original GitHub issue

Describe the bug When using methods coming from useFormContext with useEffect, it is causing updates.

To Reproduce Console will log hit on each update https://codesandbox.io/embed/react-hook-form-form-context-ki90u

Expected behavior Should not trigger a re-render

I believe that it is just the accumulation of the props causing a new value each time.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
stramelcommented, Sep 23, 2019

@bluebill1049 Sorry, I didn’t have a chance to look at this over the weekend. I’m unsure about using the hook useMemo in that way. If it works, we can keep it until we can come up with a better way to resolve it.

0reactions
bluebill1049commented, Sep 23, 2019

Should have been fixed in the latest patch

Read more comments on GitHub >

github_iconTop Results From Across the Web

useForm - watch - Simple React forms validation
This API will trigger re-render at the root of your app or form, ... useEffect 's deps, to detect value update you may...
Read more >
useForm | React Hook Form - Simple React forms validation
Name, Type, Description. onSubmit, string, Validation will trigger on the submit event and inputs will attach onChange event listeners to re-validate them.
Read more >
useForm - setValue - React Hook Form
When an error is triggered or corrected by a value update. When setValue cause state update, such as dirty and touched. It's recommended...
Read more >
useForm - trigger - Simple React forms validation
Triggers validation on multiple fields by name. trigger(["yourDetails.lastName"]). shouldFocus, boolean. Should focus the input during setting an error.
Read more >
useWatch | React Hook Form - Simple React forms validation
useWatch 's result is optimised for render phase instead of useEffect 's deps, to detect value updates you may want to use an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found