Files
supabase/apps/ui-library/registry/default/blocks/realtime-chat/hooks/use-chat-scroll.tsx
Jordi EnricandIvan Vasilov daa33f4723 add realtime chat example (#34514)
* 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>
2025-03-28 22:31:13 +01:00

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 }
}