[AccordionSummary] false positive propType warning with disableGeneration
#27363
Closed
2 tasks done
Labels
bug 🐛
Something doesn't work
component: accordion
This is the name of the generic UI component, not the React module!
v4.x
When
AccordionSummary
is checking for usage of the deprecatedclasses.focused
prop, the code callsindexOf
onclasses.focused
without checking if that property is defined. If you don't supplyclasses.focused
, this throwsFailed prop type: Cannot read property 'indexOf' of undefined
.It appears to have been introduced in this change: 9c48d0b#diff-a3e45615b0516b905db6b26935126e30763f45b8901b2bee960adb5c3be2b997R147
A workaround is to always declare
focused
as an empty string in theclasses
prop (note: this does not work in Typescript, since that class was removed from the class keys), but ideally the checker should check if it's defined first.Current Behavior 😯
An error is thrown if you use
AccordionSummary
without explicitly passingclasses.focused
Expected Behavior 🤔
No error should be thrown.
Steps to Reproduce 🕹
CodeSandbox: https://codesandbox.io/s/thirsty-ives-bwmqv
Steps:
ServerStyleSheets
withdisableGeneration: true
optionAccordionSummary
with aclasses
prop that does not includefocused
Failed prop type: Cannot read property 'indexOf' of undefined
Context 🔦
This can break tests that check that components are being passed the correct props (for example, using the prop-types-throw library: https://www.npmjs.com/package/prop-types-throw)
Your Environment 🌎
`npx @material-ui/envinfo`
The text was updated successfully, but these errors were encountered: