Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 38fe978

Browse files
gaearonbvaughn
authored andcommitted
Expose meaningful $r as fallback for functions (#1281)
1 parent 872917b commit 38fe978

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

backend/attachRendererFiber.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer):
322322
break;
323323
case HostText:
324324
nodeType = 'Text';
325+
publicInstance = fiber.stateNode;
325326
text = fiber.memoizedProps;
326327
break;
327328
case Fragment:
@@ -456,6 +457,14 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer):
456457
treeBaseDuration = fiber.treeBaseDuration;
457458
}
458459

460+
if (publicInstance === null) {
461+
// publicInstance is used for $r.
462+
// If we have nothing useful to expose, at least give props and state.
463+
// This is an escape hatch to avoid a situation where there is useful
464+
// data in the tree but DevTools don't offer any way to get it through console.
465+
publicInstance = { props, state, type };
466+
}
467+
459468
// $FlowFixMe
460469
return {
461470
nodeType,

0 commit comments

Comments
 (0)