Skip to content

Commit 72730e9

Browse files
committed
Replace useLayoutEffect with useEffect in Table
1 parent 427d3cd commit 72730e9

File tree

1 file changed

+4
-4
lines changed
  • packages/bento-design-system/src/Table

1 file changed

+4
-4
lines changed

packages/bento-design-system/src/Table/Table.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
GridWidth,
5252
Row as RowType,
5353
} from "./types";
54-
import { useLayoutEffect, useMemo, useState, CSSProperties, useEffect, useRef } from "react";
54+
import { useMemo, useState, CSSProperties, useEffect, useRef } from "react";
5555
import { match, __ } from "ts-pattern";
5656
import { useBentoConfig } from "../BentoConfigContext";
5757
import { assignInlineVars } from "@vanilla-extract/dynamic";
@@ -233,12 +233,12 @@ export function Table<
233233
.map((c) => c.id ?? c.accessor)
234234
.indexOf(stickyLeftColumnsIds[stickyLeftColumnsIds.length - 1]);
235235

236-
// Keep a style object for each sticky column, which will be updated by the useLayoutEffect below
236+
// Keep a style object for each sticky column, which will be updated by the useEffect below
237237
const [stickyLeftColumnStyle, setStickyLeftColumnStyle] = useState(
238238
{} as Record<string, CSSProperties>
239239
);
240240

241-
// Keep a state for the height of the first row of headers, which will be updated by the useLayoutEffect below
241+
// Keep a state for the height of the first row of headers, which will be updated by the useEffect below
242242
const [stickyHeaderHeight, setStickyHeaderHeight] = useState(0);
243243

244244
const tableContainerRef = useRef<HTMLDivElement>(null);
@@ -249,7 +249,7 @@ export function Table<
249249
/** Get the width of each sticky column (using the header width as reference) and use it to set the `left` of each sticky column.
250250
* Each sticky column must have as `left` the total width of the previous sticky columns.
251251
*/
252-
useLayoutEffect(() => {
252+
useEffect(() => {
253253
// Make this computation only if we have any data, because headers are not rendered when there are no rows
254254
// and we need them to get the column width.
255255
if (data.length > 0) {

0 commit comments

Comments
 (0)