@assistant-ui/react
Version:
Typescript/React library for AI Chat
26 lines • 799 B
JavaScript
"use client";
import {
createActionButton
} from "../../utils/createActionButton";
import { useCallback } from "react";
import {
useThreadViewport,
useThreadViewportStore
} from "../../context/react/ThreadViewportContext";
const useThreadScrollToBottom = () => {
const isAtBottom = useThreadViewport((s) => s.isAtBottom);
const threadViewportStore = useThreadViewportStore();
const handleScrollToBottom = useCallback(() => {
threadViewportStore.getState().scrollToBottom();
}, [threadViewportStore]);
if (isAtBottom) return null;
return handleScrollToBottom;
};
const ThreadPrimitiveScrollToBottom = createActionButton(
"ThreadPrimitive.ScrollToBottom",
useThreadScrollToBottom
);
export {
ThreadPrimitiveScrollToBottom
};
//# sourceMappingURL=ThreadScrollToBottom.js.map