mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: # Logs ``` [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 0 tag: 1432 debugValue: r1 [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 375 tag: 1432 debugValue: r2 [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 375 tag: 1432 debugValue: r2 [tid:com.facebook.react.JavaScript][UIManager.cpp:197] width: 0 tag: 1432 debugValue: r1/sealed <----------------- FIRST TAP [tid:com.facebook.react.JavaScript][UIManager.cpp:197] width: 0 tag: 1432 debugValue: r1/sealed <----------------- FIRST TAP [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 375 tag: 1432 debugValue: r4 [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 375 tag: 1432 debugValue: r5 [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 375 tag: 1432 debugValue: r6 [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 375 tag: 1432 debugValue: r7 [tid:com.facebook.react.JavaScript][ConcreteViewShadowNode.h:119] width: 375 tag: 1432 debugValue: r8 [tid:com.facebook.react.JavaScript][UIManager.cpp:197] width: 375 tag: 1432 debugValue: r7/sealed <----------------- SECOND TAP [tid:com.facebook.react.JavaScript][UIManager.cpp:197] width: 375 tag: 1432 debugValue: r7/sealed <----------------- SECOND TAP ``` # What’s happening here? Opening a *BottomSheet* and tapping the first item. As you can see before the item is tapped, it has *width* set to 375 in revision *r2*. When the tap happens, JavaScript is requesting an old revision of ShadowNode, which still has width 0. # My assumption. 1. Native creates node with *width* 0 and returns handle to *JS*. 2. Native *clones* the node, sets its *width* to 375, doesn’t tell *JS* about it. This update is due to state change. 3. *JS* tries to get the size of the node, but asking for first revision of the component it receives width 0. # Other observations 1. Manually setting width to 375 in UIManager::getRelativeLayoutMetrics fixes the problem. 2. This happens only on device, I wasn’t able to reproduce this on simulator. # Fix Find the newest revision of ShadowNodeFamily, and return its layoutMetrics. Changelog: [Internal] Reviewed By: shergin Differential Revision: D19433873 fbshipit-source-id: 4558cf6e704051e9b3968e83821d8d25b3dadcda