Skip to content

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Apr 7, 2022

No description provided.

@vercel
Copy link

vercel bot commented Apr 7, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/util/GN25CVzNHK1qvE7AdkjZVYiq3xKk
✅ Preview: https://util-git-render-react-component.vercel.app

@codecov
Copy link

codecov bot commented Apr 7, 2022

Codecov Report

Merging #292 (76ed645) into master (889d0ef) will increase coverage by 0.97%.
The diff coverage is 93.75%.

@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
+ Coverage   64.04%   65.02%   +0.97%     
==========================================
  Files          44       45       +1     
  Lines         940      972      +32     
  Branches      329      325       -4     
==========================================
+ Hits          602      632      +30     
- Misses        300      302       +2     
  Partials       38       38              
Impacted Files Coverage Δ
src/React/render.ts 93.75% <93.75%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

// Do nothing;
}

const MARK = '__rc_react_root__';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用个 Symbol?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbol IE 不兼容

try {
const mainVersion = Number((version || '').split('.')[0]);
if (mainVersion >= 18) {
({ createRoot } = require('react-dom/client'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 require 会不会对工具链有要求?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比如 webpack 和 vite。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有,不过 import 本身也是需要工具链来处理的。转换后其实其实 require:https://unpkg.com/browse/antd@4.19.5/lib/affix/index.js

Copy link
Member

@afc163 afc163 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

干脆直接用 ReactDOM 里的 createRoot 好了

Copy link
Member Author

@zombieJ zombieJ Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReactDOM 的 createRoot 会在 console 打 warning,让你用 react-dom/client 的 createRoot:

Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client". react-dom.development.js:73

@zombieJ zombieJ merged commit 5ed3625 into master Apr 11, 2022
@delete-merged-branch delete-merged-branch bot deleted the render branch April 11, 2022 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants