From 0aa1d5923a8f9f4edd8cc93a1c3eb7525c727b2b Mon Sep 17 00:00:00 2001 From: "DylanDylann (via MelvinBot)" Date: Thu, 9 Jul 2026 09:17:48 +0000 Subject: [PATCH] Fix: defer SearchPage state update out of Search render phase Co-authored-by: DylanDylann --- src/components/Search/index.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 9aa707575f2f..a275746567ac 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -764,8 +764,7 @@ function Search({ cancelSubmitFollowUpActionSpan(); } didBailToFallbackState.current = true; - onContentReady?.(); - }, [onContentReady]); + }, []); // When the render bails to an error/empty state, the SelectionList never mounts // so its onLayout callback (the primary flush site) never fires. This effect @@ -773,7 +772,17 @@ function Search({ // is intentional — we need to check after every render since bail-outs happen // in conditional returns that can't trigger state-based effects. useEffect(() => { - if (!didBailToFallbackState.current || !hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH)) { + if (!didBailToFallbackState.current) { + return; + } + // Signal overlay readiness here (post-commit) rather than inside + // cancelNavigationSpans (render phase). Calling onContentReady during + // render updates the parent SearchPage while Search is still rendering, + // which triggers React's "Cannot update a component while rendering a + // different component" warning. setIsSearchReady is idempotent, so + // firing this on every bail-out render is safe. + onContentReady?.(); + if (!hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH)) { return; } didBailToFallbackState.current = false;