How to use custom Input with Formik in React?

前端 未结 5 1277
無奈伤痛
無奈伤痛 2020-12-25 12:18

I\'m trying to use DatePicker within Formik. But when I click DatePicker\'s date its form value is not changed. Instead, I got this error:

Uncaught T

5条回答
  •  梦毁少年i
    2020-12-25 12:56

    If you have deeper nesting, you should use Formik Field. Example:

    
     {}}
    >
    
      
    
    
    
    const ColorsEditor = ({ field, colors, form, ...props }) => {
    
        return (
            
    ) }

    So the Field component already include the form, where live the setFieldValue that you can use where you need. It also include the errors and needed fields for additional customization.

提交回复
热议问题