lottie-react-native: Lottie animation doesn't play after Expo upgrade.
Description
I’m using React Native with Expo. Today I upgraded expo from version 42.0.0 to version 44.0.0(last), and I noticed that my lottie animations doesn’t play on iOS and Android. However if I change speed from current to another animation starts to work as expected. autoPlay param set to true.
Steps to Reproduce
- Use expo version ^44.0.0
- Use lottie-react-native version 5.0.1
- Use this code:
<LottieView
loop={true}
speed={1}
style={{height: hp('35%'), alignSelf: 'center'}}
autoPlay={true}
source={require('./../../../assets/lottie/noPlacesInProfile.json')}
renderMode={"SOFTWARE"}
/>
Expected behavior: Animation plays
Actual behavior: Animation doesn’t play until I change speed param.
Versions
{ npm: ‘6.14.13’, ares: ‘1.17.1’, brotli: ‘1.0.9’, cldr: ‘38.1’, icu: ‘68.2’, llhttp: ‘2.1.3’, modules: ‘83’, napi: ‘8’, nghttp2: ‘1.42.0’, node: ‘14.17.0’, openssl: ‘1.1.1k’, tz: ‘2020d’, unicode: ‘13.0’, uv: ‘1.41.0’, v8: ‘8.4.371.23-node.63’, zlib: ‘1.2.11’ expo version ^44.0.0 lottie-react-native version 5.0.1 }
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 10
- Comments: 33 (6 by maintainers)
We are also experiencing this issue.
autoPlayproperty no longer starts the animation. We also upgraded from 42 -> 44 sdk.Temp Workaround:
Hope this helps and looking forward to a fix.
I faced the same issue and I found a workaround that should work. The thing is ref is attached after first rendering, so we need to call ref.current 1 tick later.
Just wanted to chip in that I’m having the same issue and some of the solutions above were not working consistently for me but this however is consistently working for me as a workaround, the animations are always playing now:
EDIT: Actually - this turned out be inconsistent as well! Ended up with this mix of solutions in this thread:
@Amaru333 This is what I’m now using, I replaced my lottie animations with a custom component with its own ref, so this should work for you.
My workaround:
Just calling setTimeout function takes enough time as @taneba said.
@emilioicai Repo with reproducible demo app -> https://github.com/tarasvakulka/lottie-example-app There are two ways to reproduce:
None of the above workarounds worked for me, but this mish-mash combining answers from @jerearaujo03 and @salmanExpo did.
@emilioicai Did my repo with example help you to reproduce the bug ? Or may be would be better to create new issue for that ?
Hmm, interesting. If I create a completely new Expo app the
autoPlaywork as intended 🤔npx expo-cli@latest init .npx expo-cli@latest add lottie-react-nativeassetsfolder, e.g.countdown_10.jsonapp.jswith:npx expo-cli@latest startRef values shouldn’t be used as dependencies to
useStateas changing theuseRefcurrent value won’t trigger an update.We are using this workaround currently: