简体   繁体   中英

How to change formik <Field/> component's placeholder?

Basically I'm not able to make date input empty with Formik. I just want it to show nothing initially. This is what I've been dealing for hours.

 <Field
 name="date"
 type="date"
   className={`InformationForm__field text-[20px] lg:h-14 px-4 lg:py-4 py-3  outline- none 
                                           `}
                                            />

note: I've tried placeholder, giving empty string as initial value etc.

Anyone have idea?

Yo can try below code

     <Field
       name="date"
       render={({ field, form: { isSubmitting } }) => (
           <input {...field} type="date" 
            placeholder="date" />
       )}
     />

Check this link for more info:- https://formik.org/docs/api/field#render

Searching on docs I've found this prop initialValues , try that one.

Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM