On react 18 dev server, the infamous strict mode will automatically unmount and remount every component to "test if the component is resilient to remounting". Since DotLottieReact will destory the dotLottie instance when unmounting, the ref callback will always carry a null "instance".
Overview
On react 18 dev server, the infamous strict mode will automatically unmount and remount every component to "test if the component is resilient to remounting". Since
DotLottieReact
will destory thedotLottie
instance when unmounting, the ref callback will always carry anull
"instance".https://github.com/LottieFiles/dotlottie-web/blob/bb5954bff2960a34dec3f1806a0a3ba389ad4882/packages/react/src/use-dotlottie.tsx#L166-L175
Live demo: https://codesandbox.io/p/devbox/relaxed-morse-l256sp?file=%2Fapp%2Fpage.tsx
A temporary way to fix this is to disable react strict mode.
Consuming repo
dotlottie-react
Labels
Type: Bug
label to this issue.