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

19 lines
436 B
JavaScript

// @validateNoSetStateInEffects @enableAllowSetStateFromRefsInEffects @outputMode:"lint"
import {useState, useRef, useLayoutEffect} from 'react';
function Component() {
const ref = useRef({size: 5});
const [computedSize, setComputedSize] = useState(0);
useLayoutEffect(() => {
setComputedSize(ref.current.size * 10);
}, []);
return computedSize;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
};