@samitouri / QOS-React / commits / 3d44a6a486

Improved stack/fiber type-check to avoid false negative match when inst._rootNodeID is 0

Brian Vaughn committed Feb 21, 2017 at 14:41 UTC 3d44a6a4867f30b08054503956016a9401efb5b4
2 files changed +7 -5
src/renderers/native/ReactNativeComponentTree.js
+3 -1
@@ -61,7 +61,9 @@ function getInstanceFromTag(tag) {
61
62 function getTagFromInstance(inst) {
63 // TODO (bvaughn) Clean up once Stack is deprecated
64 - var tag = inst._rootNodeID || inst.stateNode._nativeTag;
64 + var tag = typeof inst.tag !== 'number'
65 + ? inst._rootNodeID
66 + : inst.stateNode._nativeTag;
67 invariant(tag, 'All native instances should have a tag.');
68 return tag;
69 }
src/renderers/native/ReactNativeGlobalResponderHandler.js
+4 -4
@@ -16,10 +16,10 @@ var ReactNativeGlobalResponderHandler = {
16 onChange: function(from, to, blockNativeResponder) {
17 if (to !== null) {
18 // TODO (bvaughn) Clean up once Stack is deprecated
19 - UIManager.setJSResponder(
20 - to._rootNodeID || to.stateNode._nativeTag,
21 - blockNativeResponder
22 - );
19 + var tag = typeof to.tag !== 'number'
20 + ? to._rootNodeID
21 + : to.stateNode._nativeTag;
22 + UIManager.setJSResponder(tag, blockNativeResponder);
23 } else {
24 UIManager.clearJSResponder();
25 }