moti: Sequence not working since reanimated 2.3.0
Since reanimated 2.3.0 I was no longer able to use Moti sequence animations
I’m getting the error:
Exception in HostFunction: Javascript worklet error
For any sequence animation
<MotiView from={{scale: 1}} animate={{scale: [1, 1.5, 1, 1.5, 1]}}>
<Text>Test</Test>
</MotiView>
I tested updating reanimated to different versions (even the last one) without luck
While creating a minimal app to reproduce the issue I found that the problem seems to be with the Hermes Engine. If Hermes is turned off the sequences seem to work properly
@nandorojo I created a repo using react-native init to reproduce the issue on iOS (adding only reanimated, moti, and enabling Hermes)
https://github.com/msantang78/MotiSequenceReproduction
I also added an animation with reanimated sequences and they seem to be working fine.
I hope it helps
For reference: I originally reported this on #131, there were other reports #140 #183
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 28 (19 by maintainers)
Commits related to this issue
- fix: sequences work again on reanimated 2.3+ See: https://github.com/nandorojo/moti/issues/195 — committed to jstheoriginal/moti by jstheoriginal 2 years ago
just merged @jstheoriginal’s PR, thanks for your patience here. will release it in the next version
this patch-package diff resolves the issue (extracted function and marked it as a worklet).
Thank you @nandorojo It is resolved. 👏👏
It looks like when i referenced the PR on our private repo and merged changes there, it closed the issue. Just reopened it! It definitely resolves the issue still. 💯
Thanks for reporting this issue. I’m also seeing this when trying to upgrade.
The issue seems to happen when it tries to call this line, since
stepAnimation
is undefined.https://github.com/nandorojo/moti/blob/881be888512d6cc6b8746a706601c74a2a55ecbf/packages/core/src/use-map-animate-to-style.ts#L425
It references this destructured
animation
outside of thegetSequenceArray
const, which does have a value when it’s destructured, but is then undefined when it’s used in getSequenceArray.https://github.com/nandorojo/moti/blob/881be888512d6cc6b8746a706601c74a2a55ecbf/packages/core/src/use-map-animate-to-style.ts#L345
example of logs: