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.

Getting errors in form api hooks

See original GitHub issue

I’m getting this error every time i try to use a function in formApi hooks Uncaught TypeError: formApi.setValue is not a function

Here is what i’m getting by consoling logging it: Screen Shot 2019-12-19 at 18 22 14

Here is my code: Screen Shot 2019-12-19 at 18 29 01

I’m using version 2.3.0 but i already tried to upgrade it.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
joepuzzocommented, Dec 20, 2019

^^^^ @victorbf yes you cant use hooks outside of the <Form />

1reaction
CRGavrilacommented, Dec 20, 2019

You can try this insteand of useFormApi:

<Form> { ({ formState, formApi }) => ( <> <Field field="fieldName"/> <button onClick={ev => { formApi .setValue('fieldName', 'test'); // or // formApi .setValues({ 'fieldName': 'test' }); }} > click button </button> </> ) }

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Hook Form - Display custom error message returned ...
This is a quick example of how to display a custom error message on a React Hook Form that is returned from an...
Read more >
useForm - setError - React Hook Form
An error that is not associated with an input field will be persisted until cleared with clearErrors . shouldFocus doesn't work when an...
Read more >
react-hook-form handling server-side errors in handleSubmit
I'm having a hard time figuring out how to handle errors that don't necessarily pertain to a single input field in a react-hook-form...
Read more >
How to handle a failed API request that is not specific to a field?
If the API request to submit the form data fails with an error that is not specific to a single form field ......
Read more >
React Hook Form Validation with Complete Examples | refine
React Hook Form uses its constraint-based validation API to validate ... the specified amount in the maxLength props, we'll get an error.
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