UNPKG

@assistant-ui/react

Version:

React components for AI chat.

17 lines 679 B
// src/primitive-hooks/thread/useThreadScrollToBottom.tsx import { useCallback } from "react"; import { useThreadViewport } from "../../context/index.mjs"; import { useThreadViewportStore } from "../../context/react/ThreadContext.mjs"; var useThreadScrollToBottom = () => { const isAtBottom = useThreadViewport((s) => s.isAtBottom); const threadViewportStore = useThreadViewportStore(); const handleScrollToBottom = useCallback(() => { threadViewportStore.getState().scrollToBottom(); }, [threadViewportStore]); if (isAtBottom) return null; return handleScrollToBottom; }; export { useThreadScrollToBottom }; //# sourceMappingURL=useThreadScrollToBottom.mjs.map