Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential for duplicate observers activation #78

Closed
fukasawah opened this issue Oct 26, 2023 · 1 comment · Fixed by #79
Closed

Potential for duplicate observers activation #78

fukasawah opened this issue Oct 26, 2023 · 1 comment · Fixed by #79

Comments

@fukasawah
Copy link
Contributor

fukasawah commented Oct 26, 2023

The onMounted hook in the infinite-loading component is asynchronous. If the parent component's onMounted process updates the infinite-loading's identifier, the watch function might get triggered first.

Reproduction Code: https://codepen.io/fukasawah/pen/poGjPaG

A suggested fix would be to call observer?.disconnect() in the infinite-loading component's onMounted hook to ensure any existing observer is disconnected before a new one is initiated, reducing the likelihood of having multiple active observers.

onMounted(async () => {
  params.parentEl = await getParentEl(target!);
  observer?.disconnect(); // <= here
  observer = startObserver(params);
});
@agm1984
Copy link

agm1984 commented Nov 7, 2023

I was suffering this bug; thanks for the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants