useField must be used inside of a <Form> component
See original GitHub issueAre you submitting a bug report or a feature request?
Bug
What is the expected behavior?
I am replacing redux-form with react-final-form in the process of upgrading in our apps react-admin v2 to v3.
<Field />
should be wrapped into <Form />
without error.
What is the current behavior?
It throw:
useField must be used inside of a <Form> component
What’s your environment?
React Final Form version 6.3.5 Final Form version 4.18.7 OS/browser affected chrome Node version, 13.5
Other information
<SimpleForm
redirect={redirect}
toolbar={(
<Toolbar redirect={redirect}>
<SaveButton redirect={redirect} />
</Toolbar>
)}
handleSubmit={this.handleSubmit}
onSubmit={() => alert('submit')}
record={record}
submitOnEnter={false}
{...rest}
>
<Wrapper>
{list.map((siteService, i) => (
<FormGroup key={siteService.name} check className={cn({ 'mt-5': !!i })}>
<Strong>
<Label check className="p-0">
<Field name="firstName" component="input" placeholder="First Name" />
<H2 className="d-inline-block">{siteService.name}</H2>
</Label>
</Strong>
</FormGroup>
))}
</Wrapper>
</SimpleForm>
With <SimpleForm />
being https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/form/SimpleForm.js
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Error: useForm must be used inside of a <Form> component ...
I fixed this by adding react-final-form to my package JSON. For some reason webpack had an issue with it being a peer dependency...
Read more >Final Form Docs – `useField()`
useField () returns FieldRenderProps . It will manage the rerendering of any component you use it in, i.e. the component will only rerender...
Read more >Form - React-admin - Marmelab
It is a headless component used internally by <SimpleForm> , <TabbedForm> , and other form components. <Form> reads the record from the RecordContext...
Read more >Advanced Usage - React Hook Form
Since most of us have to build forms with custom designs and layouts, it is our ... as a validation method, and to...
Read more >Getting error trying to use use Storybook with react-admin ...
[Solved]-Getting error trying to use use Storybook with react-admin "useField must be used inside of a <Form> component"-Reactjs. Search. score:4.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kopax could you please tell how did you solve it using mutators , i am facing the same issu
@imryanjay useField must eventually bubble up to a <Form> component. That’s the solution to this issue. If you have code to share I can be more specific.