Open nmassey opened 4 weeks ago
Latest commit: 86b8308825dd593170cfea725fd44cc6211bed32
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
react-native-reanimated-carousel | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 5, 2024 8:41pm |
I still get these warnings on newest version?
Are there any updates on this pull request? Do we know if it’s going to be merged?
Would be great if we can have this merged Thanks
Thanks for this fix! It's killing the console on Expo SDK 52 beta
Do we have an ETA on when this will be merged?
bump on this too
For me this fix did not help with all warnings. I had to remove other .value
from arrays. Here is my patch fix for 3.5.1
For me this fix did not help with all warnings. I had to remove other
.value
from arrays. Here is my patch fix
hi @LukasMod - it looks like your patch is for an older version (3.5.1) than the current mainline branch. I think those other .value
s are no longer relevant to what's on main
.
This is another reason why we need to release 4.0.0 ASAP.
Fixes #706
What: the bug
Where in our code
In
ScrollViewGesture.tsx
, we had includedtouching.value
andscrollEndTranslation.value
in the dependency arrays for a couple of React callbacks. Not only is this not necessary, but it also causes a warning message to appear (and introduces the potential performance implication mentioned below).These dependency array
.value
s were introduced in https://github.com/dohooo/react-native-reanimated-carousel/commit/eb21293d6c0544da9e62a418505945dc46a59cb6 (as a part of #116).Warning message in react-native-reanimated
As per #706 (thank you, @joaofelippe911), a console warning appears when using react-native-reanimated version 3.16.0 or higher. This new warning was added via https://github.com/software-mansion/react-native-reanimated/pull/6310
The warning looks like:
Why: potential performance implication
As per https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue/#remarks ,
What: the fix
Don't depend on
touching.value
andscrollEndTranslation.value
in our dependency arrays inuseCallback()
.These aren't needed: all accesses to
touching.value
andscrollEndTranslation.value
are within worklets, and as per https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue/#remarks :Verification: in local testing, the warning disappears!
In my local testing, this makes the warning disappear completely! And the carousel still behaves as normal.
Aside: where is this code used anyway?
In
ScrollViewGesture
, there is auseAnimatedReaction()
which callsresetBoundary()
for changes totranslation.value
wheneverpagingEnabled
isfalse
.resetBoundary()
callsactiveDecay()
in some cases... which in turn callsonFinish()
in some cases.It is worth noting that
onFinish
,activeDecay
, andresetBoundary
are only ever used whenpagingEnabled
isfalse
.(After a few minutes of playing around with my code for my use case, I was not able to cause
activeDecay()
to ever run.)