Closed rymkapro closed 6 months ago
I've created a wrapper component, something like this
const FormikInput = (props: IFormikInput) => {
const { label, form, field, keepreact } = props
const is_error = form.touched[field.name] && form.errors[field.name]
return (
<>
{label && <Label value={label} color={is_error ? 'error' : keepreact.color} />}
<TextInput
{...field}
{...keepreact}
handleOnChange={field.onChange}
color={is_error ? 'error' : keepreact.color}
/>
{is_error && (
<div className={classNames('text-rose-600 text-xs mt-0.5')}>
<ErrorMessage name={field.name} />
</div>
)}
</>
)
}
And I can't use {...field}
props because they are not fully passed, as i understood (may be i'm wrong)
Also reseting input value is not working (even without formik) Can be reproduced
const App = () => {
const [value, setValue] = useState<string>('')
return (
<div className="wrapper relative">
<TextInput value={value} handleOnChange={(e) => setValue(e.target.value)} />
<Button size="sm" onClick={() => setValue('')}>
Reset value
</Button>
</div>
)
}
export default App
Pressing "Reset value" button will not reset field value
On which dir is this code written or which branch ?
That's just an example of my code, how i tried to use keep-react input with formik Field
Can't use with Formik "from the box"