-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
fix: dependency array; removes shared value access warning from react-native-reanimated #710
fix: dependency array; removes shared value access warning from react-native-reanimated #710
Conversation
🦋 Changeset detectedLatest commit: 86b8308 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 ↗︎
|
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 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 |
hi @LukasMod - it looks like your patch is for an older version (3.5.1) than the current mainline branch. I think those other |
This is another reason why we need to release 4.0.0 ASAP. |
Please release this ASAP! @dohooo |
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 eb21293 (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 software-mansion/react-native-reanimated#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.)