Skip to content

Commit

Permalink
fix: use null as default value for ScrollObserverKey
Browse files Browse the repository at this point in the history
  • Loading branch information
diegopf committed May 2, 2024
1 parent aa02c76 commit 55a023d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@
*
* @internal
*/
const firstVisibleItemObserver: Ref<ScrollVisibilityObserver> = inject<
Ref<ScrollVisibilityObserver>
>(ScrollObserverKey as string) as Ref<ScrollVisibilityObserver>;
const firstVisibleItemObserver = inject<Ref<ScrollVisibilityObserver> | null>(
ScrollObserverKey as string,
null
);
/**
* Checks if a given value is an `ElementRef` object.
*
Expand Down Expand Up @@ -148,7 +149,9 @@
onMounted(() => {
nextTick(() => {
// Mounted does not guarantee that child components are mounted too
watch(firstVisibleItemObserver, observeItem, { immediate: true });
if (firstVisibleItemObserver) {
watch(firstVisibleItemObserver, observeItem, { immediate: true });
}
});
});
Expand Down

0 comments on commit 55a023d

Please sign in to comment.