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

dotLottieRefCallback is not getting called when initial source is empty and get filled on the next render #471

Open
ehsankh1370 opened this issue Feb 9, 2025 · 0 comments
Assignees
Labels
bug Something isn't working react

Comments

@ehsankh1370
Copy link

ehsankh1370 commented Feb 9, 2025

Overview

I am using @lottiefiles/dotlottie-react library to render some lottie animation. my initial animation source is empty cause it is coming from and api call. when this fills and my source fills it rerenders component but dotLottieRefCallbackis not getting called again so in this case i have nothing to show to the user.

Consuming repo

`
const dotLottieRefCallback = (_dotlottie: DotLottie) => {
setDotLottie(_dotlottie)
}

useEffect(() => {
if (!dotLottie) return

const handleLoad = () => {
  setIsLoaded(true)
}

const handleError = () => {
  setIsLoaded(false)
}
dotLottie.addEventListener('load', handleLoad)
dotLottie.addEventListener('loadError', handleError)

return () => {
  dotLottie.removeEventListener('load', handleLoad)
  dotLottie.removeEventListener('loadError', handleError)
}

}, [dotLottie, source])

  <DotLottieReact
    src={url}
    dotLottieRefCallback={dotLottieRefCallback}
    className={classNameCreator([className, (!url || !isLoaded) && 'invisible'])}
    loop={loop}
    {...restProps}
  />

`
...

Labels

[ Bug]

@theashraf theashraf self-assigned this Feb 10, 2025
@theashraf theashraf added bug Something isn't working react labels Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working react
Projects
None yet
Development

No branches or pull requests

2 participants