সম্পাদনা
import {createRoot} from "react-dom/client"; import React, {useLayoutEffect, useRef, useState} from "react"; function App() { const box = useRef(null); const [width, setWidth] = useState(0); useLayoutEffect(() => { setWidth(box.current.offsetWidth); }, []); return ( <div> <div ref={box}>উইথ</div> <p>{width}px</p> </div> ); } createRoot( document.getElementById("root") ).render(<App/>);
পূর্বরূপ