-
Notifications
You must be signed in to change notification settings - Fork 174
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
Getting errors in form api hooks #261
Comments
You can try this insteand of useFormApi:
|
Thanks that work it! But i solved as well, hooks works only in the children component not in the one who is calling the FORM component. Sorry about that. |
^^^^ @victorbf yes you cant use hooks outside of the |
Got stuck on this too. Maybe the docs for Almost all our forms (so far) are fully contained in one-file/one-component for simplicity (ex: contactForm.js). I wouldn't have figured it out without the comment from @CRGavrila. Re-posting that code with formatting for future reference. <Form>
{({ formApi }) => (
<Fragment>
<Field field="fieldName"/>
<button onClick={() => formApi.setValue('fieldName', 'go bananas')} >
click button
</button>
</Fragment>
)}
</Form> |
This ^^^ is in the docs on the first page |
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:
Here is my code:
I'm using version 2.3.0 but i already tried to upgrade it.
The text was updated successfully, but these errors were encountered: