-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Use compiler-safe Reanimated get/set APIs #6391
Conversation
|
})) | ||
|
||
return ( | ||
<AnimatedPressable | ||
accessibilityRole="button" | ||
onPressIn={e => { | ||
'worklet' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't a worklet. onPressIn/onPressOut run on JS already.
if (isFairlyCloseToBottom) { | ||
runOnUI(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored this to run the entire parent block on the UI thread since we've learned that otherwise every .value
access does a thread hop. Might as well run everything on UI.
39058c3
to
e5a4d92
Compare
cancelAnimation(scale) | ||
scale.value = withTiming(targetScale, {duration: 100}) | ||
scale.set(() => withTiming(targetScale, {duration: 100})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is cancelAnimation
blocking? do they need to be grouped together into a single runOnUI
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it is. don't want to change this right now, i need to better understand what cancelAnimation
does. we've heard we're not supposed to use it like this but i do remember some need for it. let's not touch for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Clicked around the app a bit and didn't run into any problems
Manually went through our codebase and fixed up all cases. I used find-all search for
useSharedValue
,useDerivedValue
, and.value
accessors.Ran into a Reanimated bug with
set()
functions, but it was easy to work around: software-mansion/react-native-reanimated#6613 (comment). You just have to add() =>
when setting it to animations, likeset(() => withStuff())
.Review without whitespace
Test Plan
Tried to find each of these components on iOS, verified common interactions work. Tried most of these Android, wouldn't expect platform differences with this API switch.
Look closely through the code:
set(withFoo())
would fail. It has to beset(() => withFoo())
. However,set(x)
is fine.