Skip to content

Alternative way to control the component from the parent #430

Description

@severo

The current way to control the state of HighTable from the parent is to pass two props: the value and the setter.

For example:

  • orderBy / onOrderByChange
  • selection / onSelectionChange
  • columnsVisibility / onColumnsVisibilityChange
  • cellPosition / onCellPositionChange

But, from #427 (review):

I kind of wish we didn't have to create a new provider for every property we want to control.

Some proposals:

  1. group some of the props, for example only one onChange event for all the events instead of onOrderByChange, onSelectionChange, etc., with different payloads, like in https://ant.design/components/table#table. Best option in my opinion (one prop per controlled state, and a common event handler).
  2. group everything in a common state + reducer...
  3. export all the intermediate context providers and components, and let the user compose them (see https://www.chakra-ui.com/docs/components/table)
  4. alternative architecture like https://tanstack.com/table/latest
  5. archive hightable and propose to use an alternative

I think 1. is a good compromise that keeps nearly the same structure and API, and does not change much of the behavior (the only challenge I see is that we would lose a way to automatically disable the user interactions (row selection, cell navigation, etc) when onXXXChange is undefined - we might want to pass an explicit prop to disable some interactions)

  1. might be too complex, 3. and 4. require changing a lot of the logic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions