moti: AnimatePresence + Hermes doesn't work
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
MotiView stuck/freeze appearing animation when wrapped in AnimatedPresence with exitBeforeEnter prop. Patch from https://github.com/nandorojo/moti/issues/195 and changes in https://github.com/nandorojo/moti/pull/200 does not fix this bug.
Bug not exists in moti@0.17.1
Steps To Reproduce
- Only happens when MotiView has multiple animated properties:
<MotiView
from={{ opacity: 0, scale: 0.9 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
/>
- Wrap MotiView into AnimatePresence with
exitBeforeEnterprop - Enable hermes in Podfile
Versions
- Moti: 0.18.0
- Reanimated: 2.9.1
- React Native: 0.67.4 - 0.69
Screenshots
Current Behavior:
https://user-images.githubusercontent.com/7981854/180895644-b2298203-076c-4f2c-9141-57cd4ebf495c.mov
Expected Behavior:
https://user-images.githubusercontent.com/7981854/180895655-e797b750-375e-4837-835b-771cd2808836.mov
Reproduction
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 28 (13 by maintainers)
Moti finally works with Hermes in version
0.22. Please upgrade and let me know if it works for you. Appreciate your patience.Thanks for the update. I’ll keep looking into it soon when I have some time. I’m convinced it’s a dependency-related issue.
Alright, I’m deeply investigating. I’ve spent hours diffing lock files. Here are some findings.
^0.17.1works^0.18does not workHere is what it looks like to install it:
I ran a diff of all files from moti and went one-by-one to see what the cause could be (yes really).
By pulling
useMotifyfrom0.17→0.18, I found that it started working again. This meant that something in the0.18change in the worklets made a difference. In that update, I improved performance by changing.forEachloops to usefor (const key of)loops. I’m wondering if Hermes didn’t like that…I tried changing
for (const key in mergedStyles)toObject.keys(mergedStyles).forEach(key =>and…that did it 🧐.So, I guess I have to refactor that back. This whole coding thing may not be for me lol