<Field /> and undefined initial value fires error
See original GitHub issueif value in <Formic initialVales>
is undefined React throws 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: https://fb.me/react-controlled-components in input (created by Field)
const InnerForm2=()=>(
<Form className={styles.Form}>
<Field type={"text"} name={"clusterName"}/>
</Form>
)
...
<Formik
validate={this.validate as any}
validateOnBlur
onSubmit={values => console.log(values)}
initialValues={{clusterName: undefined,type:1}}
component={InnerForm2 as any}
/>
...
with undefined
value <input />
rendered without value
attribute and first update causes value
rendering and this throw error
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
MUI - Select without initial value throws warnings & errors
A component is changing the uncontrolled value state of Select to be controlled. Elements should not switch from uncontrolled to controlled (or ...
Read more >using @wire and field value is returning undefined
There's a chance that your callout is happening before the wire method is returning. This component shows a trick I used to help...
Read more >e.force:createRecord - Populating defaultFieldValues ...
The reason this occurs is down to the null or undefined value being passed to the lookup field. ... Looks like there's a...
Read more >Angular Debugging "Expression has changed"
We will first start by quickly debugging the error (a video is available for this), and then we will explain the cause and...
Read more >Documentation
The Signal's value starts out equal to the passed first argument initialValue (or undefined if there are no arguments). The createSignal function returns...
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
@jaredpalmer This is fine for fields of type
string
(I’m using Typescript), you can initialize as an empty string. But for inputs of typenumber
, you have to use an initial value ofnull
orundefined
if you don’t want a value to appear in the input by default. And this continues to show the “uncontrolled input” warning.Here is my code:
I fixed it using render approach in javascript