fix(PointAnnotation): fix nested children not rendering on New Architecture (Fabric)#4231
Merged
Merged
Conversation
…bric view flattening
In React Native's New Architecture (Fabric), a View inside PointAnnotation
can get its children lifted up to become direct siblings in the native child
list. This triggers the "supports max 1 subview" error and causes the bitmap
snapshot to miss nested children (text labels disappear, only the empty outer
View is captured).
Wrapping content children in a View with collapsable={false} prevents Fabric
from flattening the user's View, so the native layer always sees a single
content child regardless of nesting depth.
Also removes the manual collapsable={false} workaround from the
PointAnnotationAnchors example, since the library now handles it.
Fixes #3682
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.
Fixes #3682
In React Native's New Architecture (Fabric), a View inside PointAnnotation can get its children lifted up to become direct siblings in the native child list. This triggers the "supports max 1 subview other than a callout" error and causes the bitmap snapshot to only capture the empty outer View — nested content (e.g. Text labels) disappears.
Root cause: Fabric's view flattening optimization removes collapsable Views from the native hierarchy and reparents their children to the nearest non-flattened ancestor — in this case, PointAnnotation itself.
Fix: Wrap content children in a
View collapsable={false}insidePointAnnotation.tsx. The native layer always sees exactly one content child regardless of how deeply the user nests views. Callout children are kept as direct native siblings (the native side identifies them by type).Also removes the manual
collapsable={false}workaround that was added to thePointAnnotationAnchorsexample — the library now handles this internally.Reproducer (before fix)
On RN 0.76+ with New Architecture: only the blue box renders, Text is missing, and the console logs
PointAnnotation supports max 1 subview other than a callout.