-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
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
rowKey -> rowKeyGetter #2190
rowKey -> rowKeyGetter #2190
Conversation
lastSelectedRowIdx.current = -1; | ||
} | ||
|
||
onSelectedRowsChange(newSelectedRows); | ||
}; | ||
|
||
return eventBus.subscribe('SelectRow', handleRowSelectionChange); | ||
}, [eventBus, isGroupRow, onSelectedRowsChange, rowKey, rows, selectedRows]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isGroupRow
changes on each render, so this was unnecessary.
src/DataGrid.tsx
Outdated
if (typeof rowKeyGetter === 'function') { | ||
const rowKey = rowKeyGetter(row); | ||
isRowSelected = selectedRows?.has(rowKey) ?? false; | ||
if (typeof rowKey === 'string' || typeof rowKey === 'number') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we still manually typecheck this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not as we are using React.Key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup
src/DataGrid.tsx
Outdated
if (typeof rowKeyGetter === 'function') { | ||
const rowKey = rowKeyGetter(row); | ||
isRowSelected = selectedRows?.has(rowKey) ?? false; | ||
if (typeof rowKey === 'string' || typeof rowKey === 'number') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not as we are using React.Key
Pros:
React.Key
.Cons:
useCallback
.