Skip to content

Commit c596e19

Browse files
Refactor TestRenderer to use correct root
1 parent f847289 commit c596e19

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/renderers/testing/ReactTestRendererFiber.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function nodeAndSiblingsArray(nodeWithSibling) {
259259
function toTree(node) {
260260
switch (node.tag) {
261261
case HostRoot: // 3
262-
return toTree(node.progressedChild);
262+
return toTree(node.child);
263263
case ClassComponent:
264264
return {
265265
nodeType: 'component',
@@ -307,12 +307,12 @@ var ReactTestFiberRenderer = {
307307
createNodeMock,
308308
tag: 'CONTAINER',
309309
};
310-
var root = TestRenderer.createContainer(container);
311-
TestRenderer.updateContainer(element, root, null, null);
310+
var root = TestRenderer.createContainer(container).stateNode;
311+
TestRenderer.updateContainer(element, root.current, null, null);
312312

313313
return {
314314
toJSON() {
315-
if (root == null || container == null) {
315+
if (root.current == null || container == null) {
316316
return null;
317317
}
318318
if (container.children.length === 0) {
@@ -324,27 +324,27 @@ var ReactTestFiberRenderer = {
324324
return container.children.map(toJSON);
325325
},
326326
toTree() {
327-
return toTree(root);
327+
return toTree(root.current);
328328
},
329329
update(newElement : ReactElement<any>) {
330-
if (root == null) {
330+
if (root.current == null) {
331331
return;
332332
}
333-
TestRenderer.updateContainer(newElement, root, null, null);
333+
TestRenderer.updateContainer(newElement, root.current, null, null);
334334
},
335335
unmount() {
336-
if (root == null) {
336+
if (root.current == null) {
337337
return;
338338
}
339-
TestRenderer.updateContainer(null, root, null);
339+
TestRenderer.updateContainer(null, root.current, null);
340340
container = null;
341341
root = null;
342342
},
343343
getInstance() {
344-
if (root == null) {
344+
if (root.current == null) {
345345
return null;
346346
}
347-
return TestRenderer.getPublicRootInstance(root);
347+
return TestRenderer.getPublicRootInstance(root.current);
348348
},
349349
};
350350
},

0 commit comments

Comments
 (0)