Skip to content

Commit 59fc938

Browse files
committed
docs (example/column-resize-performant): checking resize inside UseMemo to avoid unneccessary remounts
1 parent 02c203a commit 59fc938

File tree

1 file changed

+5
-4
lines changed
  • examples/react/column-resizing-performant/src

1 file changed

+5
-4
lines changed

examples/react/column-resizing-performant/src/main.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function App() {
190190
))}
191191
</div>
192192
{/* When resizing any column we will render this special memoized version of our table body */}
193-
{table.getState().columnSizingInfo.isResizingColumn && enableMemo ? (
193+
{enableMemo ? (
194194
<MemoizedTableBody table={table} />
195195
) : (
196196
<TableBody table={table} />
@@ -243,9 +243,10 @@ function TableBody({ table }: { table: Table<Person> }) {
243243
}
244244

245245
//special memoized wrapper for our table body that we will use during column resizing
246-
export const MemoizedTableBody = React.memo(
247-
TableBody,
248-
(prev, next) => prev.table.options.data === next.table.options.data
246+
export const MemoizedTableBody = React.memo(TableBody, (prev, next) =>
247+
next.table.getState().columnSizingInfo.isResizingColumn
248+
? prev.table.options.data === next.table.options.data
249+
: false
249250
) as typeof TableBody
250251

251252
const rootElement = document.getElementById('root')

0 commit comments

Comments
 (0)