[英]React18 is not supporting styled-component
Can anyone help me out to solve this problem.谁能帮我解决这个问题。 As I am learning React Native, I was going through styled components but was facing an error related to styled components not compatible with react18 version.在学习 React Native 时,我正在研究样式化组件,但遇到了与样式化组件与 react18 版本不兼容相关的错误。 and same works in react@16 and below同样适用于 react@16 及以下版本
I was trying to install styled-components for styling components in react-native. And i was receiving error saying that react18 is not compatible.我正在尝试为 react-native 中的样式组件安装样式组件。我收到错误消息说 react18 不兼容。 I just want styled components to work我只想让样式化的组件工作
Try to install it with this command尝试使用此命令安装它
npm install styled-components --force
I sorted the solution as styled-component
was not working for react 18.0.2.我对解决方案进行了排序,因为styled-component
不适用于 React 18.0.2。
So I decided to uninstall react 18.0.2 by using npm uninstall react@18.0.2
and then I reinstalled npm install react@17.0.2
and then I read the documentation of Styled Component所以我决定使用npm uninstall react@18.0.2
然后我重新安装npm install react@17.0.2
然后我阅读了Styled Component的文档
and installed styled-components
using yarn add styled-components
and successfully sorted out my problem.并使用yarn add styled-components
安装了styled-components
-components 并成功解决了我的问题。
npx expo install react-dom
This fixed it for me (using expo managed react-native app)这为我修复了它(使用 expo 管理 react-native 应用程序)
https://github.com/styled-components/styled-components/issues/3788#issuecomment-1335191911 https://github.com/styled-components/styled-components/issues/3788#issuecomment-1335191911
I had same problem when taking Udemy course about React Native.在参加有关 React Native 的 Udemy 课程时,我遇到了同样的问题。 This course provides git with complete code, so what I did was:本课程提供完整代码git,所以我做的是:
npm install
执行npm install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.