()
| 18 | } |
| 19 | |
| 20 | function EffectWithState() { |
| 21 | const [didMount, setDidMount] = useState(0); |
| 22 | |
| 23 | const renderCountRef = useRef(0); |
| 24 | renderCountRef.current++; |
| 25 | |
| 26 | useLayoutEffect(() => { |
| 27 | if (!didMount) { |
| 28 | setDidMount(true); |
| 29 | } |
| 30 | }, [didMount]); |
| 31 | |
| 32 | return ( |
| 33 | <ul> |
| 34 | <li>Rendered {renderCountRef.current} times</li> |
| 35 | {didMount && <li>Mounted!</li>} |
| 36 | </ul> |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | createRoot(createContainer()).render(<EffectWithState />); |
nothing calls this directly
no test coverage detected