Skip to content

Possibly rename useSelectionState to something more generic like useToggleList or useArraySubset #66

@mturley

Description

@mturley

In forklift-ui, we use useSelectionState for both checkbox selections and row expansions in tables because the state requirements are exactly the same. However, the functions returned from this hook are named very specifically for selection, so it might be nice to make them more generic (toggleItem, isItemToggled, toggleAll etc) and avoid confusing renames in destructuring like this one:

  const {
    toggleItemSelected: toggleVMExpanded,
    isItemSelected: isVMExpanded,
    selectAll: expandAll,
  } = useSelectionState<SourceVM>({
    items: sortedItems,
    isEqual: (a, b) => a.selfLink === b.selfLink,
  });

We could then create thin wrappers with specific naming if we want, like useSelectionState, useExpansionState, etc. Or we could have these functions returned in an array so they can be named on the fly, but there are so many...

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.low-priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions