Is scrolling to bottom after render a good use case for useLayoutEffect ?
For example:
useLayoutEffect(() => {
const element = divRef.current;
const { scrollHeight } = element;
element.scrollTop = scrollHeight;
}, []);
Is that any different from:
useEffect(() => {
const element = divRef.current;
const { scrollHeight } = element;
element.scrollTop = scrollHeight;
}, []);
UPDATE:
This will run on the 1st time I render my component. I don't want my users to see any flickering (i.e: I just want them to see the "already" scrolled to bottom situation). In this case, will useLayoutEffect allow me to achieve this behavior? By doing things synchronously before allowing the browser to re-paint?