hurt-tomatoH
Refine•3y ago•
11 replies
hurt-tomato

default value mui select with react-hook-form controller

Hi everyone 👋
I try to set a default value to a MUI select with the Controller from
react-hook-form
but it does not work. I found this
         <Controller
          render={({ field }) => (
            <Select {...field}>
              <MenuItem value={10}>Ten</MenuItem>
              <MenuItem value={20}>Twenty</MenuItem>
              <MenuItem value={30}>Thirty</MenuItem>
            </Select>
          )}
          name="Select"
          control={control}
        />  

code snipet in a sandbox which show us how to use a select with a control but i can not find how to set a defaultValue to the select (I try the defaultValue props but it is not working). Does any one how can i do it ?
Was this page helpful?