Skip to content

Commit

Permalink
Revert back to original useLayoutEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
blambillotte committed Oct 18, 2024
1 parent e72d01c commit 1c0d8a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/ScrollShadows.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useResizeObserver } from "@react-aria/utils";
import { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { ReactNode, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
import { Css, Palette, Properties, useTestIds } from "src";

interface ScrollShadowsProps {
Expand Down Expand Up @@ -64,7 +64,7 @@ export function ScrollShadows(props: ScrollShadowsProps) {
useResizeObserver({ ref: scrollRef, onResize });

// Hack for sizing more complicated components that might not be fully drawn on initial paint (such as a GridTable)
useEffect(() => {
useLayoutEffect(() => {
// This setTimeout (without a delay) allows the current execution thread to complete (DOM is painted with the latest render)
// by placing the callback into the async event queue to ensure the fully rendered DOM is used for the resize calculations.
setTimeout(() => onResize(), 0);
Expand Down

0 comments on commit 1c0d8a0

Please sign in to comment.