I am having difficulties expanding the accordian item as soon as state change
This is my state
const [expandedItems, setExpandedItems] = React.useState<string[]>(['item-0']);
This is my element
<Accordion className='flex flex-col' preExpanded={expandedItems} onChange={(expanded: string[]) => { setExpandedItems(expanded); }} allowZeroExpanded allowMultipleExpanded>
This is how I am updating the state
if (!expandedItems.includes(`item-${index}`)) { setExpandedItems([...expandedItems, `item-${index}`]); }
I am having difficulties expanding the accordian item as soon as state change
This is my state
const [expandedItems, setExpandedItems] = React.useState<string[]>(['item-0']);
This is my element
<Accordion className='flex flex-col' preExpanded={expandedItems} onChange={(expanded: string[]) => { setExpandedItems(expanded); }} allowZeroExpanded allowMultipleExpanded>
This is how I am updating the state
if (!expandedItems.includes(`item-${index}`)) { setExpandedItems([...expandedItems, `item-${index}`]); }
Item
<AccordionItem className='flex flex-col gap-3 px-3 py-4 border-t border-grey-base03' key={index} uuid={`item-${index}`}>