IonAccordion load

Hi. I am using IonAccordion component to display a navigation tree. It is recursive component: accordions inside accordions… It works well when all the tree is stored in a single json file… But how to do that with async loading of content/branches of tree? Before user clicked “folder” we haven’t its content, we should load it first, and then put it inside opened folder…

Hi friends. Any ideas, please? I didn’t solve it yet :frowning:

Peek 2024-01-10 01-07

I do this using tanstack query (the former react query) with Suspense.

1 Like

thank you for the answer ! :slight_smile:

You can achieve async loading for IonAccordion content by fetching the data when a folder is clicked. Use a state or variable to track the open/closed state of each accordion. When a folder is opened, trigger a data fetch and update the content dynamically. This way, content is loaded on demand, optimizing performance.