-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ssr): render same root in server #12002
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3c5b150
fix(ssr): render same root in server
MadCcc b7bce5d
chore: better string
MadCcc b5e6302
chore: better code
MadCcc 87f3ccf
chore: add DOCTYPE
MadCcc 67c7288
chore: revert
fz6m f1fc758
chore: refactor ...
fz6m 5f47177
chore: remove console
fz6m 48b3441
fix: render & hydrate full html
MadCcc 1410efc
chore: code clean
MadCcc 62b568d
chore: code clean
MadCcc 5eb28b0
chore: Merge branch 'master' into fix/ssr-use-id
MadCcc 567277d
chore: code clean
MadCcc 1593fc5
fix: SSG
MadCcc 90c089c
fix: ssg
MadCcc 04dff5b
chore: code clean
MadCcc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉这里有问题吧:
不应该在
browser.tsx
里导入server.tsx
的东西,会造成 browser 运行时和 node 运行时混在一起,如果要复用应该单独抽取文件出来。最重要的是这里服务端有
loaderData
的 html 发送给用户,而用户的 js 代码里 hydrate 的是一个没有loaderData
的 html 树,这不一致吧。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里虽然看上去是不一致的但是不会导致注水失败。这段脚本如果只是修改 window 参数的话可以考虑放到 head 里
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注水的具体机制我还没有深挖过,目前做的尝试发现不是所有情况下的 html 不一致都会打断注水,比如 head 里的标签数量等,会保留服务端的 html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无论是否会注水正确,我认为都不应该从 html 开始 hydrate ,因为不管是社区共识还是 react 官方文档,都统一从 react root 节点开始 hydrate 保持一致,应该保持这个基本原则。