Files
bun-src/test/bundler/transpiler/react-compiler-fixtures/valid-setState-in-useLayoutEffect-from-ref.js
2026-08-27 21:09:14 +00:00

20 lines
474 B
JavaScript

// @validateNoSetStateInEffects @enableAllowSetStateFromRefsInEffects @outputMode:"lint"
import {useState, useRef, useLayoutEffect} from 'react';
function Tooltip() {
const ref = useRef(null);
const [tooltipHeight, setTooltipHeight] = useState(0);
useLayoutEffect(() => {
const {height} = ref.current.getBoundingClientRect();
setTooltipHeight(height);
}, []);
return tooltipHeight;
}
export const FIXTURE_ENTRYPOINT = {
fn: Tooltip,
params: [],
};