I need to populate a menu with items from an api request.
I made some sample items; const items
. Some of the menu items have children, and the children can also have children, so I need to nest several levels of menu items.
I made an Accordion()
with Collapsible from react-native-collapsible and an AccordionItem()
for items that have no children.
function App()
renders the menu items twice. Once by manually adding Accordion
s and AccordionItem
s and once by mapping items[]
. RootMenuItem()
is called for each top level item and renders that item and its sub-items by recursion.
When manually adding each item it works the way I want it to. I need to populate the menu programatically, but nested accordions rendered by RootMenuItem()
are misbehaving on android and iOS. When testing in Web on snack.io it seems to be working fine.
Here is a snack with my complete App.js: https://snack.expo.dev/@dissar/nested-collapsibles
Am I doing something wrong? Does anybody have any tips for doing this in a better way?
PS: The dynamically rendered items have weird widths when testing on snack.io, but don't worry about that.