React re-renders recursively, and when it comes across the element that preserves its referential identity from the previous render, it can stop the recursion.
That's why component composition can be used as an alternative to memoization.
How to refactor an existing client component into a server component?
1. Move the state to the URL
2. Move data fetching to the server
3. Isolate interactivity into a smaller client component
How to update React components on scroll or mousemove with good performance and without refs?
Colocate the state with the parts of the UI that need to change.
Client components are like units of interactivity in otherwise server-rendered or even statically generated pages.
They can live on the leaves of your component tree or even wrap the server components, providing interactivity to server-rendered / statically generated content.
"use client" marks a boundary between the server and client code on the module dependency tree.
Every component imported in a file with "use client" automatically becomes a client component.
We can still pass server components as props to the client components.
React Server Component that streams GPT response to HTML during page load (runs in the latest
@nextjs
)
No client code is involved. Just recursive Suspense.
I've got a lot of requests for code examples for A Visual Guide to React Rendering.
So I've built this Code Sandbox that you can use as an interactive companion to the articles.
👆
By default, Next.js will generate routes statically at build time.
Here are the things that make the route render dynamically at the request time instead: