Skip to content
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:react 17 报错问题 (#216) #217

Merged
merged 13 commits into from Apr 23, 2022
Merged

fix:react 17 报错问题 (#216) #217

merged 13 commits into from Apr 23, 2022

Conversation

SunLxy
Copy link
Contributor

@SunLxy SunLxy commented Apr 23, 2022

  1. react-dom 小于 v18版,命令行会有Module not found:Error: Can't resolve 'react-dom/client' 这个报错,可以忽略

@vercel
Copy link

vercel bot commented Apr 23, 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/398188662/react-code-preview/AhzoDJ5YdAcLkEek79DaKqL47a3p
✅ Preview: https://react-code-preview-git-fork-sunlxy-master-398188662.vercel.app

package.json Outdated
"@uiw/react-github-corners": "~1.5.14",
"@uiw/react-markdown-preview": "~4.0.6",
"@uiw/react-github-corners": "~1.5.3",
"@uiw/react-markdown-preview": "~3.5.1",
Copy link
Member

Choose a reason for hiding this comment

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

@SunLxy"@uiw/react-markdown-preview": "~4.0.6" 报错?

// 判断是否是 react v18版本
const isV18 = Reflect.has(V18ReactDOM || {}, 'createRoot');
const isV18 = Reflect.has(V18ReactDOM, 'createRoot');
const NewReactDOM = isV18 ? ReactDOMRender(V18ReactDOM) : V18ReactDOM;
Copy link
Member

Choose a reason for hiding this comment

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

@SunLxy 处理方法仍然有问题,我们的代码放到 codepen 和 codesandbox 中是可以预览的

image

@jaywcjlove
Copy link
Member

@SunLxy 文档中的示例处理一下。

@jaywcjlove
Copy link
Member

jaywcjlove commented Apr 23, 2022

https://codesandbox.io/s/uiw-react-code-preview-react-18-1bmhhd?from-embed=&file=/src/App.js

在 React 18 下面报警告。 @SunLxy

Warning: ReactDOM.render is no longer supported in React 18.
Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.
 Learn more: https://reactjs.org/link/switch-to-createroot

@SunLxy
Copy link
Contributor Author

SunLxy commented Apr 23, 2022

@SunLxy
Copy link
Contributor Author

SunLxy commented Apr 23, 2022

umd 中报警告的等着修复吧 facebook/react#24274

@jaywcjlove
Copy link
Member

@SunLxy 👍

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.

None yet

2 participants