question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Material UI Select throwing error

See original GitHub issue

When wrapping the Select Component with Controller I get this error (The NativeSelect Component from MUI works as expected.):

Material-UI: A component is changing the uncontrolled value state of Select to be controlled.
Elements should not switch from uncontrolled to controlled (or vice versa).
Decide between using a controlled or uncontrolled Select element for the lifetime of the component.
The nature of the state is determined during the first render, it's considered controlled if the value is not `undefined`.


My sample code is:

<FormControl >
                <InputLabel>Priority</InputLabel>
                <Controller
                  as={
                    <Select>
                     <MenuItem value="low">Low</MenuItem>
  <MenuItem value="high">High</MenuItem>

                    </Select>
                  }
                  name="priority"
                  native={false}
                  control={control}
                />
              </FormControl>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
zszepcommented, Jun 8, 2020

Yes. This solves the problem. Maybe this should be documented as it is not very intuitive. NativeSelect does not need the defaultValue parameter and all the samples I could find use NativeSelect.

0reactions
gregStevenardcommented, Oct 27, 2020

This is happening to me too. @acrellin have you been able to fix this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make a 'Select' component as required in Material UI ...
For setting a required Select field with Material UI, you can do: class SimpleSelect extends React.PureComponent { state = { selected: null, ...
Read more >
React Select component - Material UI - MUI
Select components are used for collecting user provided information from a list of options.
Read more >
Using Material UI with React Hook Form - LogRocket Blog
Learn how to use Material UI with React Hook Form by building a complete ... a Controller component from React Hook Form, it...
Read more >
Material UI Example - Redux Form
For Material UI, @erikras has published a set of wrapper components to use ... error}> <InputLabel htmlFor="age-native-simple">Age</InputLabel> <Select ...
Read more >
Material UI multi select problem - The freeCodeCamp Forum
How do I make it display like the dropdown list item? I did try to type selected[i18n.language].join(', ') but it throws an error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found