-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prevent flattening style arrays (#7021)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary ### Why While integrating `Unistyles` with `Reanimated`, 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 by `Unistyles`. ### How To fix this, we just need to remove ~two~ one occurrence~s~ of array flattening. I tested it locally with `Unistyles`, and I can correctly retrieve the `style` prop as-is. `Unistyles` have to retrieve `ref` + `style` prop while [borrowing ref](https://www.unistyl.es/v3/other/babel-plugin#3-component-factory-borrowing-ref). Additionally, with this change, I can treat `Reanimated` styles as inline styles. Since inline styles are not processed by `Unistyles` algorithm, this can completely eliminate issues such as preventing animations when switching themes or changing device orientation. <!-- Explain the motivation for this PR. Include "Fixes #<number>" if applicable. --> ## Test plan <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. --> 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.
- Loading branch information
Showing
5 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters