-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove unnecessary color processing in interpolateColor
#6213
Remove unnecessary color processing in interpolateColor
#6213
Conversation
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.
LGTM but let's wait for @piaskowyk's approval
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.
According to my test and our runtimetests it works 🎉
this change has caused an issue in our project when using When i roll back to 3.13.0 that doesn't include this change the color works as expected. @piaskowyk Can we revert this change or fix the issues it has with animated props? |
It seems like this should be fixed with software-mansion/react-native-svg#2397 |
Hello @jesse-one-app,
|
@bohdanprog we were not calling thanks for the example and the help! |
Summary
Our
interpolateColor
function seems to have some unnecessary color processing in it. It was added some 3-4 years ago and should not be needed by now.Why
There is a function called
rgbaColor
which is used inhsvToColor
(which in turn is used only ininterpolateColor
) as well as directly ininterpolateColor
. So it's safe to say it is used only there. All it does is take r,g,b,a values, runs a small check on them and then returns a rgba string.It has a check whether we are on UI thread or not. If we were on UI, it returned a number-formatted color (formatted for native platforms) instead of the usual rgba string. The problem is, these values are then directly returned from the function. I believe it was needed back then, but now we have a function called
processColorInProps
which does exactly that + it doesn't interfere with returned values ofinterpolateColor
. Taking all these things into consideration, I believe this check inrgbaColor
function is not needed anymore.Moreover, it creates problems. When
interpolateColor
gets called on UI thread (for example by using it insideuseDerivedValue
hook as shown by this issue: #6119), the user gets these number-formatted colors which don't work when passed anywhere.Test plan
Copy
App.tsx
from snack linked to the mentioned issue and make sure the text stays blue. Also, check out Color Interpolation example from the example app.Tested on iOS and Android (both Paper and Fabric) as well as Web. I've noticed neither issues nor regressions.