Distinguish transparent colors from undefined props - #58093
Open
ngocdevv wants to merge 1 commit into
Open
Conversation
Abbondanzo
requested changes
Aug 24, 2026
| Color color_; | ||
| // Android represents both transparent black and UndefinedColor as ARGB 0. | ||
| // Track presence separately so prop reconciliation can distinguish them. | ||
| bool isDefined_; |
Contributor
There was a problem hiding this comment.
By leaking Android details into the SharedColor implementation, UndefinedColor loses its meaning. Instead, this responsibility should be shifted into the HostPlatformColor struct for Android to mirror what iOS, macOS, and Windows do: define undefined Color separately. You could define a new struct for Android
struct Color {
int32_t value{0};
bool isDefined{false};
constexpr Color() = default;
};
This way Color{} != Color{0}
It's a bit less surgical to do it this way, but avoids future footguns if anyone were to reach for UndefinedColor
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 #58085.
Android represents both an undefined color and explicit transparent black as ARGB
0.SharedColorpreviously compared only that raw value, so Props 2.0 considered an explicitly supplied transparent color equal to an absent prop and omitted it from the mount diff.This change tracks color presence separately from the platform value and includes it in equality, boolean conversion, and hashing. Platform parsers and the few call sites that intentionally produce an undefined color now preserve that state explicitly.
Changelog:
[ANDROID] [FIXED] - Preserve explicitly transparent colors during Props 2.0 reconciliation.
Test Plan:
ColorTest.testTransparentColorIsDistinctFromUndefined.Color.cpp; it failed before this change and passes afterward.ReactAndroidCMake Debug forarm64-v8asuccessfully.git diff --check.