You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accordion has boolean two related input props: expandeddefaultExpanded
The API docs says that both defaults to false.
This is wrong and misleading.
expanded defaults to undefined . Which is different (and is treated very differently) from false.
Precisely, MUI assumes that the component is uncontrolled if (and only if) expanded (the "controlled value", as in useControlled hook) is undefined .
If the docs were right, then writing <Accordion defaultExpanded /> (or equivalently <Accordion defaultExpanded ={true} /> would be the same as writing <Accordion defaultExpanded expanded={false} />- which obviously is not the case
Current behavior 😯
No response
Expected behavior 🤔
No response
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
The text was updated successfully, but these errors were encountered:
hbjORbj
changed the title
Wrongly documented default props in controlled/uncontrolled components
[docs] Wrongly documented default props in controlled/uncontrolled components
Jan 16, 2023
Duplicates
Latest version
Steps to reproduce 🕹
This applies to several components , I'll take Accordion as an example but it also applies eg to Checkbox
https://mui.com/material-ui/api/accordion/
Accordion has boolean two related input props:
expanded
defaultExpanded
The API docs says that both defaults to
false
.This is wrong and misleading.
expanded
defaults toundefined
. Which is different (and is treated very differently) fromfalse
.Precisely, MUI assumes that the component is uncontrolled if (and only if)
expanded
(the "controlled value", as inuseControlled hook
) isundefined
.If the docs were right, then writing
<Accordion defaultExpanded />
(or equivalently<Accordion defaultExpanded ={true} />
would be the same as writing<Accordion defaultExpanded expanded={false} />
- which obviously is not the caseCurrent behavior 😯
No response
Expected behavior 🤔
No response
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: