Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
React-hook-form: unable to successfully implement MUI Select component

I'm trying to create a wrapper around the MUI Select component, and while I've found some solutions that seem to be really close to working. They simply don't and I'm not sure why.

I've attached a picture of the error plus the related code. Any ideas how to get around this?

source template I'm trying to use

error message

enter image description here

my controller

<FormControl>
  <Controller
    name="sourceLanguage"
    rules={{ required: 'this is required' }}
    control={control}
    defaultValue={sourceLanguage}
    as={
      <Select>
        <MenuItem value="">None</MenuItem>
        <MenuItem value="fr">French</MenuItem>
        <MenuItem value="es">Spanish</MenuItem>
      </Select>
    }
  />
</FormControl>

useForm hook

  const {
    control,
    handleSubmit,
    getValues,
    formState: { errors },
  } = useForm<dynamicFormState>({});

related state

export interface dynamicFormState {
  title: string;
  description: string;
  contentId: string;
  sourceURL: string;
  sourceLanguage: string;
  targetLanguage: string;
  author?: IYoutubeAuthor;
  content?: IYoutubeContent;
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It seems you're mixing RHF's v6 and v7. Your <Controller /> component uses v6 syntax with the as prop, while you're probably using v7 as a dependency in your project (therefore the TS error noting that as is not a property of <Controller />). Write your <Controller /> using the render prop instead of as should fix the error.

<FormControl>
  <Controller
    name="sourceLanguage"
    rules={{ required: 'this is required' }}
    control={control}
    defaultValue={sourceLanguage}
    render={({ field }) => (
      <Select {...field}>
        <MenuItem value="">None</MenuItem>
        <MenuItem value="fr">French</MenuItem>
        <MenuItem value="es">Spanish</MenuItem>
      </Select>  
    )}
  />
</FormControl>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!