Skip to content

Commit

Permalink
fix: πŸ› cleanup for eventListeners (#241)
Browse files Browse the repository at this point in the history
* fix: πŸ› cleanup for eventListeners

* chore: πŸ€– added changeset
  • Loading branch information
afsalz authored Sep 26, 2023
1 parent c1d0f54 commit b5e2b23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-dots-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dotlottie/react-player': patch
---

fix: πŸ› cleanup for eventListeners
8 changes: 8 additions & 0 deletions packages/react-player/src/react-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ export const DotLottiePlayer = React.forwardRef<DotLottieCommonPlayer | null, Pr
dotLottieCommonPlayerRef.current.addEventListener('data_failed', onDataFailed);
dotLottieCommonPlayerRef.current.addEventListener('complete', onComplete);
dotLottieCommonPlayerRef.current.addEventListener('loopComplete', onLoopComplete);

return (): void => {
dotLottieCommonPlayerRef.current.removeEventListener('DOMLoaded', onDOMLoaded);
dotLottieCommonPlayerRef.current.removeEventListener('data_ready', onDataReady);
dotLottieCommonPlayerRef.current.removeEventListener('data_failed', onDataFailed);
dotLottieCommonPlayerRef.current.removeEventListener('complete', onComplete);
dotLottieCommonPlayerRef.current.removeEventListener('loopComplete', onLoopComplete);
};
}, []);

useEffect(() => {
Expand Down

0 comments on commit b5e2b23

Please sign in to comment.