Add hacks to make React ART not warn from devtools
Ben Alpert committed
May 14, 2016 at 15:34 UTC
7ecff6a437bb79d0129005df782d8829a457141a
1 file changed
+17
-2
src/renderers/shared/stack/reconciler/ReactMultiChild.js
+17
-2
@@ -12,6 +12,7 @@
12
'use strict';
13
14
var ReactComponentEnvironment = require('ReactComponentEnvironment');
15
+var ReactInstanceMap = require('ReactInstanceMap');
16
var ReactInstrumentation = require('ReactInstrumentation');
17
var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
18
@@ -142,14 +143,28 @@ function processQueue(inst, updateQueue) {
143
var setParentForInstrumentation = emptyFunction;
144
var setChildrenForInstrumentation = emptyFunction;
145
if (__DEV__) {
146
+ var getDebugID = function(inst) {
147
+ if (!inst._debugID) {
148
+ // Check for ART-like instances. TODO: This is silly/gross.
149
+ var internal;
150
+ if ((internal = ReactInstanceMap.get(inst))) {
151
+ inst = internal;
152
+ }
153
+ }
154
+ return inst._debugID;
155
+ };
156
setParentForInstrumentation = function(child) {
157
+ invariant(child._debugID != null, 'mooooooooooooooooooo');
158
if (child._debugID !== 0) {
147
- ReactInstrumentation.debugTool.onSetParent(child._debugID, this._debugID);
159
+ ReactInstrumentation.debugTool.onSetParent(
160
+ child._debugID,
161
+ getDebugID(this._debugID)
162
+ );
163
}
164
};
165
setChildrenForInstrumentation = function(children) {
166
ReactInstrumentation.debugTool.onSetChildren(
152
- this._debugID,
167
+ getDebugID(this),
168
children ? Object.keys(children).map(key => children[key]._debugID) : []
169
);
170
};