mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
* add realtime chat * yolo * clean up avatar references, leaving those out * allow to pass messages and receive message change state * add more names to reduce prob of same name popping up int he example * update registry, add nextjs docs * add more usage examples * Minor changes on the realtime chat component. * Regenerate the registry. * docs --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
18 lines
406 B
TypeScript
18 lines
406 B
TypeScript
import { useCallback, useRef } from 'react'
|
|
|
|
export function useChatScroll() {
|
|
const containerRef = useRef<HTMLDivElement>(null)
|
|
|
|
const scrollToBottom = useCallback(() => {
|
|
if (!containerRef.current) return
|
|
|
|
const container = containerRef.current
|
|
container.scrollTo({
|
|
top: container.scrollHeight,
|
|
behavior: 'smooth',
|
|
})
|
|
}, [])
|
|
|
|
return { containerRef, scrollToBottom }
|
|
}
|