NamH 0bad1a479f
fix: remove scroll animation chat screen (#2819)
Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
2024-04-25 17:24:29 +07:00

30 lines
553 B
TypeScript

import { ReactNode, useEffect, useRef } from 'react'
type Props = {
children: ReactNode
}
const ListContainer: React.FC<Props> = ({ children }) => {
const listRef = useRef<HTMLDivElement>(null)
useEffect(() => {
const scrollHeight = listRef.current?.scrollHeight ?? 0
listRef.current?.scrollTo({
top: scrollHeight,
behavior: 'instant',
})
})
return (
<div
ref={listRef}
className="flex h-full w-full flex-col overflow-y-scroll"
>
{children}
</div>
)
}
export default ListContainer