diff --git a/packages/react-refresh/src/__tests__/ReactFresh-test.js b/packages/react-refresh/src/__tests__/ReactFresh-test.js index e14cdcfe32cb5..f5148f36040a6 100644 --- a/packages/react-refresh/src/__tests__/ReactFresh-test.js +++ b/packages/react-refresh/src/__tests__/ReactFresh-test.js @@ -902,8 +902,22 @@ describe('ReactFresh', () => { await patch(() => { const Test = React.forwardRef((props, ref) => { const [count, setCount] = React.useState(0); + const handleClick = () => setCount(c => c + 1); + + // Ensure ref is extensible + const divRef = React.useRef(null); + React.useEffect(() => { + if (ref) { + if (typeof ref === 'function') { + ref(divRef.current); + } else if (Object.isExtensible(ref)) { + ref.current = divRef.current; + } + } + }, [ref]); + return ( -