From e4b777ef453cc951655b87b214328f7a4bea1493 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Wed, 23 Mar 2022 11:30:21 +0100 Subject: [PATCH 1/2] Update rsc refresh typing and doc example --- docs/api-reference/next/streaming.md | 2 ++ packages/next/client/index.tsx | 2 +- packages/next/client/streaming/refresh.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/api-reference/next/streaming.md b/docs/api-reference/next/streaming.md index 210b18c48df3..ef5f6e8dc635 100644 --- a/docs/api-reference/next/streaming.md +++ b/docs/api-reference/next/streaming.md @@ -88,6 +88,8 @@ export default function Search() { { refresh() + // Or if you want to update props of that server component page, you can do: + // refresh(nextProps) }} /> ) diff --git a/packages/next/client/index.tsx b/packages/next/client/index.tsx index cd2f3fc315b2..941c51bcd9db 100644 --- a/packages/next/client/index.tsx +++ b/packages/next/client/index.tsx @@ -808,7 +808,7 @@ if (process.env.__NEXT_RSC) { const startTransition = (React as any).startTransition const rerender = () => dispatch({}) // If there is no cache, or there is serialized data already - function refreshCache(nextProps: any) { + function refreshCache(nextProps?: any) { startTransition(() => { const currentCacheKey = getCacheKey() const response = createFromFetch( diff --git a/packages/next/client/streaming/refresh.ts b/packages/next/client/streaming/refresh.ts index 7caa504a4deb..c79d3c21ecd3 100644 --- a/packages/next/client/streaming/refresh.ts +++ b/packages/next/client/streaming/refresh.ts @@ -1,6 +1,6 @@ import { createContext, useContext } from 'react' -export const RefreshContext = createContext((_: any) => {}) +export const RefreshContext = createContext((_props?: any) => {}) export function useRefreshRoot() { return useContext(RefreshContext) From 0a996baa8afc7e58c795bed89932617dda74246d Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Wed, 23 Mar 2022 12:57:01 +0100 Subject: [PATCH 2/2] Update docs/api-reference/next/streaming.md Co-authored-by: Shu Ding --- docs/api-reference/next/streaming.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-reference/next/streaming.md b/docs/api-reference/next/streaming.md index ef5f6e8dc635..90b651435677 100644 --- a/docs/api-reference/next/streaming.md +++ b/docs/api-reference/next/streaming.md @@ -88,7 +88,7 @@ export default function Search() { { refresh() - // Or if you want to update props of that server component page, you can do: + // Or refresh with updated props: // refresh(nextProps) }} />