vercel / next-react-server-components

Demo repository for Next.js + React Server Components
https://next-rsc-hn.vercel.app
MIT License
979 stars 158 forks source link

How to rerender RSC? #8

Closed Regaron closed 2 years ago

Regaron commented 2 years ago

How can we rerender(refetch) RSC to show updated data?

huozhi commented 2 years ago

@Regaron We have undocumented API now in latest version of next.js could let you do that. Docs update will come soon.

Example

import { unstable_useRefreshRoot } from 'next/streaming'

export deafult function Page() {
   cons refresh = unstable_useRefreshRoot()
   // ...
   return <Content><button onClick={refresh}>update</button></Content>
}

Would love to hear the feedback from you