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.

Correct way to set input defaults using controller

See original GitHub issue

Describe the question?

Long story short… I’ve built the form using a smart form ish pattern. I need to set defaultValues from redux state. I’ve tried to both setting defaultValues and useEffect/reset. On the actual input I’ve set defaultValue="" which overrides what defaultValues and reset has set. I figured I can use defaultValue on a input, so I wouldn’t have write a function to figure out everything in defaultValues upfront. I have a very large form with nested inputs. Using watch on each component was unbearable. Any way to fix this. I’m thinking I have something setup incorrectly.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-hook-form-controller-fbssm
  2. 4th input should say Josh

Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-controller-fbssm

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
zenzjtechcommented, Apr 23, 2020

Yes, I’ve figured out now! Sorry for the the obvious ignorance. It seems for Controlled React-number-format, it’s necessary to add the name: value of the field to defaultValues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set react hook form default values when using ...
1 Answer 1 · Set the default values for all of your inputs via an object. (Key: input's name value: input default value...
Read more >
How To Set Up Controller Input In Under 3 Minutes In Unreal ...
In this video I go over how to set up controller input so we can control are character with one in are game...
Read more >
WTF Is? Controller: Set Input Mode in Unreal Engine 4 ( UE4 )
What are the Controller : Set Input Mode Nodes in Unreal Engine 4Source Files: https://github.com/MWadstein/wtf-hdi-files.
Read more >
Controller | React Hook Form - Simple React forms validation
You need to either set defaultValue at the field-level or useForm 's defaultValues . undefined is not a valid value. If your form...
Read more >
Connect a wireless game controller to your Apple device
Open Bluetooth settings on your Apple device, then select the controller ... You can use the Buddy Controller feature to combine inputs from ......
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