Next.js 真的是越来越难用了,什么狗屁 use client,不如 Astro 一根,有什么话跟我的岛屿说去吧

10 天前
 u3u

5614 次点击
所在节点    Next.js
49 条回复
runlongyao2
9 天前
Plumbiu
9 天前
@rocmax RSC 就是会水和整个页面,至少水和的数据都是包括静态部分的,见 https://github.com/vercel/next.js/discussions/42170 。更明显的例子就是我博客实际 HTML 内容只有不到 4k 个字符,水和数据有 1 百万个字符
rocmax
9 天前
@Plumbiu rsc payload 中会有一份服务端渲染结果的副本,用来在客户端建立与服务器端相同的组件树,而不是用来 hydration 。rsc 渲染生成静态内容不包含 js ,没有 hydration 的必要。

1. HTML is used to immediately show a fast non-interactive preview of the route to the user.
2. RSC Payload is used to reconcile the Client and Server Component trees.
3. JavaScript is used to hydrate Client Components and make the application interactive.

https://nextjs.org/docs/app/getting-started/server-and-client-components#on-the-client-first-load
SayHelloHi
9 天前
从某个版本开始 路由有 App 路由和 Page 路由

就开始懵了 看着头晕
长时间不写代码 再次写 Next 项目就得去翻文档 😂
Plumbiu
9 天前
@rocmax 我觉得你把水和的概念缩小了,水和就是包括还原组件树
beyondstars
9 天前
这种框架本身是非常 opinionated 的
rocmax
9 天前
@Plumbiu 文档上明白写着,你觉得有啥用
Plumbiu
9 天前
@rocmax 其实我想说的是 React 的水和包括还原组件树,hydrateRoot 方法就能看出来,需要接受用户的根组件 https://react.dev/reference/react-dom/client/hydrateRoot#hydrating-server-rendered-html
rocmax
9 天前
@Plumbiu rsc 渲染产物中没有 logic ,也不需要 interactive ,hydrateRoot 会跳过它们直到遇到 use client 。

To hydrate your app, React will “attach” your components’ logic to the initial generated HTML from the server. Hydration turns the initial HTML snapshot from the server into a fully interactive app that runs in the browser.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://ex.noerr.eu.org/t/1141028

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX