fix: lazy load

This commit is contained in:
Shusui MOYATANI
2024-01-07 09:44:39 +09:00
parent b00f7765ac
commit 1b5c9dc563

View File

@@ -17,6 +17,7 @@ const LazyLoad: Component<LazyLoadProps> = (props) => {
entries.forEach((entry) => { entries.forEach((entry) => {
if (entry.isIntersecting) { if (entry.isIntersecting) {
setVisible(true); setVisible(true);
observer.disconnect();
} }
}); });
}, },
@@ -34,12 +35,10 @@ const LazyLoad: Component<LazyLoadProps> = (props) => {
}); });
return ( return (
<div ref={containerRef}> <Show when={visible()} fallback={<div ref={containerRef}>{props.fallback}</div>} keyed>
<Show when={visible()} fallback={props.fallback} keyed> {/* eslint-disable-next-line @typescript-eslint/no-unused-vars */}
{/* eslint-disable-next-line @typescript-eslint/no-unused-vars */} {(_) => props.children()}
{(_) => props.children()} </Show>
</Show>
</div>
); );
}; };