score:1

Accepted answer

the argument type for onchange changes when the react-select receives ismulti from a single object to a list of objects. when using ismulti you don't need to destruct; the first parameter is the value.

you also want to make the react-select a controlled component by managing its value.

export default function selectfield(props) {
  const [field, state, { setvalue, settouched }] = usefield(props.field.name);
  
  // value is an array now
  const onchange = (value) => {
    setvalue(value);
  };

 // use value to make this a  controlled component
 // now when the form receives a value for 'campfeatures' it will populate as expected
  return <select {...props} value={state?.value} ismulti onchange={onchange} onblur={settouched} />;
}

the new value is an array of the selected options with label and value fields. if you want to store just the value you'll need to map it to a value and modify the react-select to handle that


Related Query

More Query from same tag