Skip to content

Instantly share code, notes, and snippets.

@bherrero
Created April 27, 2017 21:50
Show Gist options
  • Select an option

  • Save bherrero/2e2e7cce6a23d06cfaee45d59ff52719 to your computer and use it in GitHub Desktop.

Select an option

Save bherrero/2e2e7cce6a23d06cfaee45d59ff52719 to your computer and use it in GitHub Desktop.

Revisions

  1. bherrero revised this gist Apr 27, 2017. No changes.
  2. bherrero created this gist Apr 27, 2017.
    13 changes: 13 additions & 0 deletions SectionList.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    // maps it's an array of objects
    // groupBy to extract section headers
    let dataSource = _.groupBy(maps, o => o.name);
    // reduce to generate new array
    dataSource = _.reduce(dataSource, (acc, next, index) => {
    acc.push({
    key: index,
    data: next
    });
    return acc;
    }, []);

    return dataSource;