sanniassin / react-input-mask

Input masking component for React. Made with attention to UX.
MIT License
2.24k stars 255 forks source link

InputMask contains an input of type undefined with both value and defaultValue props. #287

Open jsnavarroc opened 2 years ago

jsnavarroc commented 2 years ago

When implementing the component, show this error.

Warning: InputMask contains an input of type undefined with both value and defaultValue props. Input elements must be either 
controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled
or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components
 <InputMask
        {...leftover}
        mask={'99'}
        disabled={true}
        value={leftover.value || ''}
        defaultValue={leftover.defaultValue || ''}
        className={`input-time-text input-time ${disabledClass}`}
   />
ttasca commented 1 year ago

I'm using Formik + react-input-mask and my case missed including the field "initialValues={{". Example: < Formik innerRef={formikRef} initialValues={{ phone: '', }} My field looks like this:

{({ field }) => ( )}

in your case you would have to see the more complete code.