The NewTable API has behaviors like selecting and sort extracted into hooks.
You can attach these hooks to your table to enhance the experience.
We want to stress that the usage of these hooks is completely optional, you can
create all of these behaviors on your own and by hand.
The objective is to cover the majority of the cases with the hooks and other APIs but still
have the option of overwriting any default, creating flexibility.
How to use the useSelectable hook
This hook provides functionality to make it easier to build tables with selectable rows.
It handles the logic of managing checkbox states.
The hook receives your data Array and an optional config Object with the following
type definition:
type ConfigObject={
/* An unique attribute of the elements in the data array. Default: 'id' */
key?: string,
/* An array of unique identifiers that will be initially selected */
initialState?:Array<string>,
}
Keep in mind that the key needs to be a unique value, otherwise the hook will
select multiple values with the same key.