Skip to content

Commit

Permalink
fix: since solid is optimizing the reactivity the first version does …
Browse files Browse the repository at this point in the history
…not work without the observed props being above the if (#329)
  • Loading branch information
johann-crabnebula authored Jul 2, 2024
1 parent 177c0f6 commit 5f84d1e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions clients/web/src/components/virtual-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ export function VirtualList<VirtualItem>(props: {
virtualizer.scrollElement?.addEventListener("wheel", checkScrollDirection);
});

createEffect(() => {
if (
autoScrollStarted ||
!props.shouldAutoScroll ||
!props.dataStream.length
)
return;
const initAutoScroll = (
shouldAutoScroll: boolean | undefined,
length: number,
) => {
if (!shouldAutoScroll || !length || autoScrollStarted) return;
requestAnimationFrame(autoScroll);
};

createEffect(() => {
initAutoScroll(props.shouldAutoScroll, props.dataStream.length);
});

return (
Expand Down

0 comments on commit 5f84d1e

Please sign in to comment.