Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material-UI slider not exposing name prop to Formik

I'm using react,formik and material-ui to build out an application that I'm trying to add a slider to. For some reason, it appears that the Material-UI slider component is not exposing the name prop to formik which causes formik to through a warning and not use the value from the slider. The warning says that you've called handleChange but not provided id or name

I've created a CodeSandbox that shows the issue I'm having. I managed to find 1 issue on GitHub but Material UII closed it saying that they aren't fixing it and that it has to be handled in userland.

I'm wondering if anyone else has come across this and managed a workaround for it.

like image 474
Railto Avatar asked Mar 09 '20 11:03

Railto


1 Answers

I figured it out. Changed the onChange prop from onChange={handleChange} to onChange={(event, value) => setFieldValue('slider', value)}

like image 196
Railto Avatar answered Nov 05 '22 20:11

Railto