We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently useRowSelect's state prop behaves as an uncontrolled state only.
state
We had a requirement where we wanted to support controlled selection for the Table selections.
Example:
const [selectedRows, setSelectedRows] = React.useState([]); <WrapperTable selectedIds={selectedRows} onSelectionChange={({ selectedIds }) => { setSelectedRows(selectedIds) }} />
Pseudo Implementation code:
const WrapperTable = ({ data, onSelectionChange, selectedIds, defaultSelectedIds }) => { // controllable controlled/uncontrolled state const [selectedRows, setSelectedRows] = useControllableState({ defaultValue: defaultSelectedIds, value: selectedIds, onChange: (value) => { onSelectionChange?.({ selectedIds: value, }); }, }); const onSelectChange: MiddlewareFunction = (action, state): void => { // Logic for updating state setSelectedRows(() => selectedIds); }; const rowSelectConfig = useRowSelect( data, { onChange: onSelectChange, state: { ids: selectedRows } }, { rowSelect: 'multiple' }, ); return <ReactTable data={data} select={rowSelectConfig} /> }
Is there any way to achieve this?
I'm also willing to raise a PR for adding this feature in useRowSelect
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Currently useRowSelect's
state
prop behaves as an uncontrolled state only.We had a requirement where we wanted to support controlled selection for the Table selections.
Example:
Pseudo Implementation code:
Is there any way to achieve this?
I'm also willing to raise a PR for adding this feature in useRowSelect
The text was updated successfully, but these errors were encountered: