Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to re render Accordion to make it expandable automatically on state change #371

Open
saloni-dhiwise opened this issue Aug 14, 2024 · 2 comments

Comments

@saloni-dhiwise
Copy link

No description provided.

@saloni-dhiwise
Copy link
Author

saloni-dhiwise commented Aug 14, 2024

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}`}>

@saloni-dhiwise
Copy link
Author

State is getting updated as I logged it, but Item is not getting auto expanded as soon as state gets updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant