From 8bee920542587141b6d90d9202105aa5420ddd0a Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Tue, 25 Jul 2023 13:41:59 +0100 Subject: [PATCH] fix[devtools/updateFiberRecursively]: mount suspense fallback set in timed-out case --- .../react-devtools-shared/src/backend/renderer.js | 12 ++++++++++++ packages/react-devtools-shared/src/hook.js | 2 +- .../react-reconciler/src/ReactFiberDevToolsHook.js | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index e694339687483..506afcedcf36c 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -2345,6 +2345,18 @@ export function attach( const prevFallbackChildSet = prevFiberChild ? prevFiberChild.sibling : null; + + if (prevFallbackChildSet == null && nextFallbackChildSet != null) { + mountFiberRecursively( + nextFallbackChildSet, + shouldIncludeInTree ? nextFiber : parentFiber, + true, + traceNearestHostComponentUpdate, + ); + + shouldResetChildren = true; + } + if ( nextFallbackChildSet != null && prevFallbackChildSet != null && diff --git a/packages/react-devtools-shared/src/hook.js b/packages/react-devtools-shared/src/hook.js index 39af7daa374ce..4df992e23ea61 100644 --- a/packages/react-devtools-shared/src/hook.js +++ b/packages/react-devtools-shared/src/hook.js @@ -320,7 +320,7 @@ export function installHook(target: any): DevToolsHook | null { let uidCounter = 0; - function inject(renderer: ReactRenderer) { + function inject(renderer: ReactRenderer): number { const id = ++uidCounter; renderers.set(id, renderer); diff --git a/packages/react-reconciler/src/ReactFiberDevToolsHook.js b/packages/react-reconciler/src/ReactFiberDevToolsHook.js index f10806af18803..f9103b85801c8 100644 --- a/packages/react-reconciler/src/ReactFiberDevToolsHook.js +++ b/packages/react-reconciler/src/ReactFiberDevToolsHook.js @@ -56,6 +56,7 @@ export function injectInternals(internals: Object): boolean { // No DevTools return false; } + const hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; if (hook.isDisabled) { // This isn't a real property on the hook, but it can be set to opt out