Skip to content

Commit

Permalink
Update rsc refresh typing and doc example (#35543)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
huozhi and shuding committed Mar 25, 2022
1 parent 4e8e191 commit d5e1225
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/api-reference/next/streaming.md
Expand Up @@ -88,6 +88,8 @@ export default function Search() {
<SearchUI
onChange={() => {
refresh()
// Or refresh with updated props:
// refresh(nextProps)
}}
/>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/next/client/index.tsx
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion 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)
Expand Down

0 comments on commit d5e1225

Please sign in to comment.