Accordion Breaks if Expanded is not passed as props
Issue Description
Just upgraded to the latest version and found my app crashing. Took a look at the code and seems to have found the problem.
Accordion.js:176
const { expanded, expandMultiple } = this.props;
// eslint-disable-next-line no-unused-vars
let selected;
if (expanded !== undefined && expanded !== null) {
selected = Array.isArray(expanded) ? expanded : [expanded];
selected = expandMultiple ? selected : selected.slice(0, 1);
}
this.state = {
selected: props.expanded
};
If expanded is not passed, state selected gets set to undefined or something. This cause the line below to fail, because we cannot get indexOf of undefined.
Accordion.js:231
renderItem={({ item, index }) => (
<AccordionItem
disable={disable === index}
key={String(index)}
item={item}
expanded={this.state.selected.indexOf(index) !== -1}
:184 looks like an obvious bug to me, but I'm not sure since there is a line explicitly disabling eslint. Sorry if I got things wrong. For now my workaround is to pass an empty array to the expanded prop.
<Accordion
dataArray={this.state.mydata}
animation={true}
expanded={[]}
+1 Have the same problem today after upgrade to 2.15.2
Just add Array to expanded prop is all that you need to fix it:
Original example from Doc:

The right example:

Got the same problem and also laugh out loud when realized that other errors were caused by passing number (as the type asks) to "expanded" prop. The component actually expects an array but the interface requires a number.