Update rsc refresh typing and doc example (#35543)

* Update rsc refresh typing and doc example

* Update docs/api-reference/next/streaming.md

Co-authored-by: Shu Ding <g@shud.in>

Co-authored-by: Shu Ding <g@shud.in>
This commit is contained in:
Jiachi Liu 2022-03-25 22:54:07 +01:00 committed by GitHub
parent 4e8e191a6e
commit d5e122594d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View file

@ -88,6 +88,8 @@ export default function Search() {
<SearchUI
onChange={() => {
refresh()
// Or refresh with updated props:
// refresh(nextProps)
}}
/>
)

View file

@ -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(

View file

@ -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)