How to use the react-widgets/lib/util/_.groupBySortedKeys function in react-widgets

To help you get started, we’ve selected a few react-widgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jquense / react-widgets / packages / virtualized / src / VirtualList.js View on Github external
static getDataState(data, { groupBy }, lastState) {
    let initial = { flatData: data }
    lastState = lastState || initial

    if (lastState.data !== data || lastState.groupBy !== groupBy) {
      if (!groupBy) return initial

      let keys = []
      let groups = groupBySortedKeys(groupBy, data, keys)

      let sequentialData = []
      let flatData = []
      keys.forEach(group => {
        let items = groups[group]
        let groupItem = { __isGroup: true, group }
        sequentialData = [...sequentialData, ...items]
        flatData = [...flatData, groupItem, ...items]
      }, [])

      return {
        groups,
        groupBy,
        flatData,
        sequentialData,
        sortedKeys: keys,