React hook to scroll chat feed
Used in 100ms and many of my Chat applications.
useChatScroll.tsx
import React from 'react' function useChatScroll<T>(dep: T): React.MutableRefObject<HTMLDivElement> { const ref = React.useRef<HTMLDivElement>(); React.useEffect(() => { if (ref.current) { ref.current.scrollTop = ref.current.scrollHeight; } }, [dep]); return ref; }