Page 1 of 1

Accordion ActiveIndex

Posted: 04 Feb 2019, 04:47
by lharley
I am not quite a newbie to React after 6 months of coding, but I'm still learning. Is there a good working example of the Accordion component? The documentation and source for the Accordion don't show an example where the ActiveIndex is set to something other than the default. It is also not clear how to open and close a tab programmatically.

I have an accordion, set to multiple={true} and 4 accordion tabs. I need to have one or more tabs open depending on what happens above on the 'page.' If I set the default tab to anything other than zero, I get an error "activeIndexOf is not a function." How can I pass two indices to the Accordion, so two tabs are open?

Re: Accordion ActiveIndex

Posted: 04 Feb 2019, 18:31
by lharley
I did some experiments and with the error messages I was able to determine that the activeIndex actually wants an array of index numbers. By using activeIndex=[0,3] I was able to set two of the AccordionTabs to open state.

I wish the documentation for Prime React Accordion was written better, so newbies like myself could learn React easier.