Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Make default Table isEmptyRow (#2370)
Browse files Browse the repository at this point in the history
* Make default Table isEmptyRow

* isEmptyRow optional + add to useCallback deps
  • Loading branch information
dharit-tan authored Dec 9, 2022
1 parent f90a081 commit 17c9248
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/web/src/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const dateSorter = (accessor: string) => (rowA: any, rowB: any) => {
return 0
}

const isEmptyRow = (row: any) => {
// Used in TracksTable, CollectiblesPlaylistTable
const isEmptyRowDefault = (row: any) => {
return Boolean(!row?.original?.uid || row?.original?.kind === Kind.EMPTY)
}

Expand All @@ -84,6 +85,7 @@ type TableProps = {
onReorder?: (source: number, destination: number) => void
onShowMoreToggle?: (setting: boolean) => void
onSort?: (...props: any[]) => void
isEmptyRow?: (row: any) => boolean
pageSize?: number
scrollRef?: React.MutableRefObject<HTMLDivElement | undefined>
showMoreLimit?: number
Expand Down Expand Up @@ -112,6 +114,7 @@ export const Table = ({
onReorder,
onShowMoreToggle,
onSort,
isEmptyRow = isEmptyRowDefault,
pageSize = 50,
scrollRef,
showMoreLimit,
Expand Down Expand Up @@ -438,7 +441,8 @@ export const Table = ({
renderSkeletonRow,
isReorderable,
renderDraggableRow,
renderTableRow
renderTableRow,
isEmptyRow
]
)

Expand Down Expand Up @@ -474,7 +478,7 @@ export const Table = ({

const isRowLoaded = useCallback(
({ index }) => !isEmptyRow(rows[index]),
[rows]
[rows, isEmptyRow]
)

// Pagination Functions
Expand Down

0 comments on commit 17c9248

Please sign in to comment.