oblador / react-native-collapsible

Animated collapsible component for React Native, good for accordions, toggles etc
MIT License
2.43k stars 455 forks source link

Array of items in a section #395

Open hcphoon01 opened 3 years ago

hcphoon01 commented 3 years ago

I'm trying to setup an accordion that has a nested array of sections, like this

[
  {
    id: 1,
    title: "First",
    content: [
      {
        id: 1,
        section: 1,
        name: "First Section First Item"
      },
      {
        id: 2,
        section: 1,
        name: "First Section Second Item",
      },
    ],
  },
  {
    id: 2,
    title: "Second",
    content: [
      {
        id: 3,
        section: 2,
        name: "Second Section First Item"
      },
    ],
  },
]

How could I go about rendering this in an accordion? Could a flat list be used, if so how would that work?

oblador commented 3 years ago

You should be able to do that with a nested Accordion. You can use the flat list option too, but only for the outer Accordion