I ran into this problem some time ago. Material ui select don't use the same change handlers like the input and text fields.
Formik provides us with a change handler called(handleChange) as props so you can use that.
That is what i used in the example below
constCreateUserForm=({classes})=>{const{values:{username,password,role},errors,touched,handleChange,isValid,setFieldTouched,handleSubmit,isRequesting}=props;constusers=[{value:"admin",label:"admin"},{value:"cndidate",label:"candate"},{value:"examiner",label:"examiner"},{value:"examadmin",label:"examadmin"}];constchange=(name,e)=>{e.persist();handleChange(e);setFieldTouched(name,true,false);};return(<formclassName={classes.form}onSubmit={handleSubmit}><TextFieldid="role"selectlabel="Role"className={classes.textField}value={role}onChange={handleChange("role")}SelectProps={{MenuProps:{className:classes.menu}}}helperText="Please select your role"margin="normal"variant="outlined">{users.map(option=>(<MenuItemkey={option.value}value={option.value}>{option.label}</MenuItem>
))}</TextField>
<Buttontype="submit"fullWidthvariant="contained"color="primary"className={classes.submit}disabled={!isValid}>CreateUser</Button>
</form>
);};
so your onChange should be onChange={handleChange('building')} , building being the name for that select
So I guess my question now is how can I customize handleChange? For simplicity, what I need to be able to do is make an axios call, sending select's value onChange.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I ran into this problem some time ago. Material ui select don't use the same change handlers like the input and text fields.
Formik provides us with a change handler called(handleChange) as props so you can use that.
That is what i used in the example below
so your onChange should be
onChange={handleChange('building')},buildingbeing thenamefor that selectSo I guess my question now is how can I customize handleChange? For simplicity, what I need to be able to do is make an axios call, sending select's value onChange.