this works fine on form submit shows selected value when I add onChange event then on form submit it doesnot show selected value
<Controller name="CostCenterGrp" className="form-control" control={control} render={({ field, value}) => ( <ReactSelect {...field} isClearable options={costCenterHeads} value={value} /> )}`
CodePudding user response:
You need to add field.onchange inside the component to manual edit the value field.onChange(event);
<Controller
render={({ field }) => <input onChange={event=>{
handleSampleChange(event);
field.onChange(event);
}} />}
name="sample"
control={control}
/>