score:0

use a callback ref.

function example() {
    const [divref, setdivref] = usestate(null);

    useeffect(() => {
        if (divref && divref.clientheight > 0) {
            div.scrollintoview({
                behavior: 'auto',
                block: 'center',
                inline: 'center',
            });
        }
    }, [divref]);

    return <div ref={setdivref} />;
}

Related Query

More Query from same tag