-
-
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
feat: prevent flattening style arrays #7021
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.
Added one more check for objects
I tried to apply the changes locally and had some styles not being applied anymore. Since the However, I tried with the following: // Kept as before
const styles = flattenArray<StyleProps>(styleProp ?? []);
// Only apply this change
props[key] = processedStyle; And I didn't have any warning anymore, and the regression I saw previously didn't happen in this case. Did you try that too? |
Yeah, but is array of arrays a valid |
@jeremybarbet nevertheless you're right! It's just a one liner and I can still get Array on my side. Thanks for the verification 🙏🏼 I will update PR. |
I updated few tests to indicate that we may have style arrays now |
packages/react-native-reanimated/src/createAnimatedComponent/PropsFilter.tsx
Show resolved
Hide resolved
I think these warnings are not from my PR. I didn't use |
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 tested it, and it looks good 👍
To fix CI run:
then we can merge it 😄 |
Dziękuję serdecznie 😊 🫡 |
Summary
Why
While integrating
Unistyles
withReanimated
, there is one clash that I would love to resolve.We encourage developers to merge styles using array syntax, as it makes it easier to detect the order of merging and persist the C++ state attached to styles.
Reanimated flattens arrays passed to the
style
prop, making it impossible to distinguish which props are animated and which are provided byUnistyles
.How
To fix this, we just need to remove
twoone occurrencesof array flattening. I tested it locally withUnistyles
, and I can correctly retrieve thestyle
prop as-is.Unistyles
have to retrieveref
+style
prop while borrowing ref.Additionally, with this change, I can treat
Reanimated
styles as inline styles. Since inline styles are not processed byUnistyles
algorithm, this can completely eliminate issues such as preventing animations when switching themes or changing device orientation.Test plan
I tested it locally and I'm happy with the outcome. But I do understand that you have own test suites and regression tests, so I hope this won't break anything.