Reputation: 201
When i try to use React hook form and material ui component i received the following error
Warning: A component is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info.
When i tried to use inputRef it is still not working.
<TextField
autoFocus
margin="dense"
id="name"
label="Name"
type="text"
fullWidth
inputRef={register}
/>
{ <Controller
as={TextField}
name='test'
control={control}
placeholder='test'
>}
Upvotes: 0
Views: 1529
Reputation: 2346
You don't need the controller for a simple TextInput
field. You should get rid of it and see if your warning dissappear.
Upvotes: 0
Reputation: 955
Please set the value that will resolve your uncontrolled input problem.
value={ this.state.value || "" }
Upvotes: 1