From 2f7951892ec8613a05458db2263f2de94112a0d2 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Mon, 14 Feb 2022 22:35:05 +0100 Subject: [PATCH] fix double render in strict mode (#34333) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/next/client/index.tsx | 4 +++- .../react-streaming-and-server-components/app/next.config.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/next/client/index.tsx b/packages/next/client/index.tsx index 8115aab7519d6..3e408f1cefe6c 100644 --- a/packages/next/client/index.tsx +++ b/packages/next/client/index.tsx @@ -775,9 +775,11 @@ if (process.env.__NEXT_RSC) { serialized?: string _fresh?: boolean }) => { + React.useEffect(() => { + rscCache.delete(cacheKey) + }) const response = useServerResponse(cacheKey, serialized) const root = response.readRoot() - rscCache.delete(cacheKey) return root } diff --git a/test/integration/react-streaming-and-server-components/app/next.config.js b/test/integration/react-streaming-and-server-components/app/next.config.js index ae1bd8cf8ebc6..add280d239bb3 100644 --- a/test/integration/react-streaming-and-server-components/app/next.config.js +++ b/test/integration/react-streaming-and-server-components/app/next.config.js @@ -1,6 +1,7 @@ const withReact18 = require('../../react-18/test/with-react-18') module.exports = withReact18({ + reactStrictMode: true, onDemandEntries: { maxInactiveAge: 1000 * 60 * 60, },