Fix inherited animated text color on native#490
Open
yaminyassin wants to merge 1 commit into
Open
Conversation
0d8d4f4 to
07a4bd8
Compare
07a4bd8 to
36f0cf2
Compare
workflow: benchmarks/perf (native)Comparison of performance test results, measured in operations per second. Larger is better.
|
workflow: benchmarks/sizeComparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.
|
Contributor
Author
|
@martinbooth could you take a look at this? When could we expect a release if it merges? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #426.
Fixes inherited animated text color on native when a parent has a color transition and a child uses
color: inherit.The inherited style path already copied the resolved parent color into the child style, but it did not mark the child as needing an Animated renderer when the inherited value was animated. That meant a child text node could receive an animated color value while still rendering as regular
Textinstead ofAnimated.Text.This updates inherited style resolution to detect inherited
AnimatedNodevalues and set the internalanimatedflag so the native renderer selects the Animated component.Why this happens
Transitions create animated style values with
Animated.Value().interpolate(...).For direct styles, the transition path already causes the component to render with an Animated renderer. The bug appears when the animated value is inherited:
color.color: inherit.useStylePropsresolves the inherited value and assigns it to the child style.Text, even though itscolorstyle was animated.Why this fix
The native renderer needs to know whether the resolved style contains a real React Native animated node. So we add and export AnimatedNode from react-native.
The
AnimatedNodedeep import is wrapped throughsrc/native/react-native, matching the existing convention for React Native internals.Test plan
npm run jest --workspace react-strict-dom -- --selectProjects "react-strict-dom (Native)" tests/html/html-test.native.js --runInBand --watchman=falsenpx flow focus-check packages/react-strict-dom/src/native/react-native/AnimatedNode.js packages/react-strict-dom/src/native/react-native/index.js packages/react-strict-dom/src/native/modules/useStyleProps.js packages/react-strict-dom/tests/html/html-test.native.jsnpm run lint:report -- --quiet packages/benchmarks/perf/rollup.config.mjs packages/benchmarks/perf/mocks/react-native.js packages/benchmarks/perf/mocks/AnimatedNode.jsnpm run build --workspace react-strict-domnpm run perf --workspace benchmarks -- -o /tmp/rsd-perf-pr490.jsongit diff --check origin/main...HEAD