Skip to content

Commit 1680413

Browse files
committed
修复useAutoScroll钩子中的scrollTo调用,确保在container存在时才执行滚动
1 parent bdb36ed commit 1680413

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/hooks/useAutoScroll.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export const useAutoScroll = <T extends HTMLDivElement>(
4444
(currentScrollHeight > prevScrollHeight &&
4545
(isNearBottom || isLocked.current));
4646

47-
if (shouldScroll) {
48-
container.scrollTo({
47+
if (shouldScroll && container.scrollTo) {
48+
container.scrollTo?.({
4949
top: currentScrollHeight,
5050
behavior: 'smooth',
5151
});

0 commit comments

Comments
 (0)