Unverified Commit d5e12259 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

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: 's avatarShu Ding <g@shud.in>
Co-authored-by: 's avatarShu Ding <g@shud.in>
parent 4e8e191a
...@@ -88,6 +88,8 @@ export default function Search() { ...@@ -88,6 +88,8 @@ export default function Search() {
<SearchUI <SearchUI
onChange={() => { onChange={() => {
refresh() refresh()
// Or refresh with updated props:
// refresh(nextProps)
}} }}
/> />
) )
......
...@@ -808,7 +808,7 @@ if (process.env.__NEXT_RSC) { ...@@ -808,7 +808,7 @@ if (process.env.__NEXT_RSC) {
const startTransition = (React as any).startTransition const startTransition = (React as any).startTransition
const rerender = () => dispatch({}) const rerender = () => dispatch({})
// If there is no cache, or there is serialized data already // If there is no cache, or there is serialized data already
function refreshCache(nextProps: any) { function refreshCache(nextProps?: any) {
startTransition(() => { startTransition(() => {
const currentCacheKey = getCacheKey() const currentCacheKey = getCacheKey()
const response = createFromFetch( const response = createFromFetch(
......
import { createContext, useContext } from 'react' import { createContext, useContext } from 'react'
export const RefreshContext = createContext((_: any) => {}) export const RefreshContext = createContext((_props?: any) => {})
export function useRefreshRoot() { export function useRefreshRoot() {
return useContext(RefreshContext) return useContext(RefreshContext)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment