I use Material-UI and Formik. I want that two input fields can edit a single value. In this case there is a TextField and a Slider and both of those inputs should allow to change the value for the perdiod
. When I give both input fields the same id I get the following error message, which I kinda expected: Formik cannot determine which value to update
But is there a way to do that with Formik or do I need to write a custom handleChange function?
const formik = useFormik({
initialValues: {
period: 5,
},
<OutlinedInput
id="period"
name="period"
type="period"
onChange={formik.handleChange}
value={formik.values.period}
/>
<Slider
value={formik.values.period}
aria-label="Default"
min={0}
max={20}
id="period"
onChange={formik.handleChange}
/>
CodePudding user response:
dont give them the same id , but give them the same name