-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore: Clean up getViewProp implementation #8056
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
base: main
Are you sure you want to change the base?
Conversation
// @ts-ignore this is fine | ||
const viewTag = animatedRef() as number; | ||
const result = await getViewProp(viewTag, 'opacity', animatedRef.current); | ||
const result = await getViewProp(animatedRef.current, 'opacity'); |
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 know that this params order change is a breaking change but, since the viewTag
was the first param, I had to move all params (and I took liberty of changing the order of params to get the component as the first param and the prop name as the second one).
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.
Why don't we just pass animatedRef
instead of animatedRef.current
?
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 is how it was working before - we were passing a component instance instead of a ref object. It will be also a bit harder to type this method properly if we wanted to pass a ref (it should accept React's ref, as well as, our animated ref)
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 talked with @tjzel and we decided to add method on the animated ref for easier usage. The old API will remain unchanged for backwards compatibility.
1973991
to
d5345d9
Compare
d5345d9
to
4632dfc
Compare
// @ts-ignore this is fine | ||
const viewTag = animatedRef() as number; | ||
const result = await getViewProp(viewTag, 'opacity'); | ||
const result = await animatedRef.getViewProp<number>('opacity'); |
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'm not sure if we want getViewProp
to be in the public API of Reanimated. This method is meant for runtime tests and should not be used by apps as far as I know.
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.
Mhm, it was exported as a function but not documented, so maybe you are right that this was meant only for the internal use. What should I do then if it is not a part of the public API? Can I restore previous changes that just removed the unused param from the function signature and not care about backwards compatibility?
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.
If it's not a part of the public API then we can import it from src/
directly in the runtime tests, instead of putting it in public exports.
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.
- Let's not care about backwards compatibility
- Let's convert it from ref method back to a standalone function
- I'm okay with moving it to
src/
directory
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.
Generally, it looks okay, but I agree with Tomek's suggestions. Let's adjust to Tomek's comments from here - and we'll be good to go.
Summary
This PR removes unused
viewTag
prop from thegetViewProp
function which is a leftover from the old Paper-compatible implementation.Test plan
I tested it on the
getViewProp
example (which for some reason was disabled before on Fabric, likely because of the invalidgetViewProp
implementation).Screen.Recording.2025-08-12.at.00.26.35.mp4