Repository navigation
Description
Description
I found this writing a C++ Fabric component whose shadow node answers its own baseline only while a prop asks for it: once the prop changes to ask, the node sits on its bottom edge in a row with alignItems: 'baseline' rather than on its baseline.
YogaLayoutableShadowNode connects Yoga's baseline function only in the constructor that builds a node from its first props, when BaselineYogaNode is among the traits it is given (YogaLayoutableShadowNode.cpp#L82-L86). A clone takes its source's traits (ShadowNode.cpp#L123) and a copy of its source's Yoga node (YogaLayoutableShadowNode.cpp#L94-L101). The function that calls baseline(), yogaNodeBaselineCallbackConnector, is private (YogaLayoutableShadowNode.h#L166), and no header declares the layout context it passes (YogaLayoutableShadowNode.cpp#L64, #L1011-L1012). So no member connects it after construction: setting BaselineYogaNode on a clone whose new props ask for a baseline changes nothing, and without a function of its own, Yoga takes a leaf's baseline at its bottom edge (Baseline.cpp#L57-L58). enableMeasurement() connects the measure function after construction; nothing does the same for the baseline function.
Setting the trait in BaseTraits() instead connects the function on every node of the component. For a component whose nodes also lay out children, that changes their baseline too: Yoga asks a node with a baseline function for its baseline before it looks at its children (Baseline.cpp#L18-L33), so those nodes answer the component's baseline() in place of the baseline Yoga takes from their children (Baseline.cpp#L35-L62).
Expected: a revision whose props ask for a baseline can connect the function, as enableMeasurement() connects the measure function, and the node sits on the baseline it answers.
I opened the fix as #60571.
Steps to reproduce
The reproducer's BaselineLeaf is a C++ component registered in the app's OnLoad.cpp (BaselineLeafShadowNode.h): a 50x80 measured leaf whose baseline() answers 20 while its answersBaseline prop is true. While answersBaseline is true, its first revision hands BaselineYogaNode to the constructor that reads it, and a clone sets the trait itself. App.tsx renders two rows of a 50x40 box and the leaf with alignItems: 'baseline': in the first, the leaf's first props ask for its baseline; in the second, its props ask once the row has laid out.
cd ReproducerApp && yarn install && cd android && ./gradlew assembleRelease && adb install -r app/build/outputs/apk/release/app-release.apk- Open the app. The first row reads
from-the-start answersBaseline=true box y=0 leaf y=20; the second readsafter-first-layout answersBaseline=true box y=40 leaf y=0, its leaf's bottom edge on the box's.
Expected: the second row reads box y=0 leaf y=20 too, its leaf's baseline, 20 from its top, on the box's bottom edge.
bash ./reproduce.sh runs both steps on an attached device and exits 1 while the second row's leaf sits on its bottom edge.
React Native Version
0.90.0-nightly-20261204-82ae0577d
Affected Platforms
Runtime - Android, Build - Windows
Areas
Fabric - The New Renderer
Output of npx @react-native-community/cli info
[…]
System:
OS: Windows 11 10.0.26300
CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor "
Memory: 128.69 GB / 255.67 GB
Binaries:
Node:
version: 26.13.1
[…]
Yarn:
version: 1.22.22
[…]
npm:
version: 12.2.1
[…]
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
Versions:
- 10.0.19041.0
- 10.0.26100.0
IDEs:
Android Studio: AI-262.9437.185.2621.16467767
Visual Studio: Not Found
Languages:
Java:
version: 17.0.20.1
[…]
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 22.0.0-alpha.0
wanted: 22.0.0-alpha.0
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.90.0-nightly-20261204-82ae0577d
wanted: 0.90.0-nightly-20261204-82ae0577d
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
[…]
MINGW64_NT-10.0-26300 x86_64, node v26.13.1, openjdk version "17.0.20.1" 2026-08-18 LTS
device: SM-S911B, Android 14 (API 34), arm64-v8a
react-native 0.90.0-nightly-20261204-82ae0577d
== ./gradlew :app:assembleRelease -PreactNativeArchitectures=arm64-v8a
from-the-start answersBaseline=true box y=0 leaf y=20
after-first-layout answersBaseline=false box y=40 leaf y=0
after-first-layout answersBaseline=true box y=40 leaf y=0
screenshot: screenshot.png
after its props change, the leaf sits on its bottom edge: box y=40, leaf y=0, where its baseline puts it at box y=0, leaf y=20
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/rn-baseline-after-construction
Screenshots and Videos
No response
Activity
[-]A shadow node whose new props ask for a baseline can't connect React Native's baseline function, so a leaf aligns on its bottom edge[/-][+]`YogaLayoutableShadowNode` has no member that connects the baseline function after construction, so without a function of its own, a leaf whose new props ask for a baseline stays aligned on its bottom edge[/+]