Skip to content

Instantly share code, notes, and snippets.

@jacobdo2
Last active November 28, 2021 08:02
Show Gist options
  • Save jacobdo2/512e40e155fd64777e989dcfb3efc249 to your computer and use it in GitHub Desktop.
Save jacobdo2/512e40e155fd64777e989dcfb3efc249 to your computer and use it in GitHub Desktop.
function Child({ name, shouldScrollTo }) {
const ref = useRef()
useEffect(() => {
shouldScrollTo && ref.current.scrollIntoView({behavior: "smooth"});
}, []);
return <div ref={ref}>{name}</div>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment