Skip to content

Commit 5f84d1e

Browse files
fix: since solid is optimizing the reactivity the first version does not work without the observed props being above the if (#329)
1 parent 177c0f6 commit 5f84d1e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

clients/web/src/components/virtual-list.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ export function VirtualList<VirtualItem>(props: {
5353
virtualizer.scrollElement?.addEventListener("wheel", checkScrollDirection);
5454
});
5555

56-
createEffect(() => {
57-
if (
58-
autoScrollStarted ||
59-
!props.shouldAutoScroll ||
60-
!props.dataStream.length
61-
)
62-
return;
56+
const initAutoScroll = (
57+
shouldAutoScroll: boolean | undefined,
58+
length: number,
59+
) => {
60+
if (!shouldAutoScroll || !length || autoScrollStarted) return;
6361
requestAnimationFrame(autoScroll);
62+
};
63+
64+
createEffect(() => {
65+
initAutoScroll(props.shouldAutoScroll, props.dataStream.length);
6466
});
6567

6668
return (

0 commit comments

Comments
 (0)