react-native - 为什么 styled-components 5.x 会警告 "Expected style to contain units."

标签 react-native styled-components

当使用 Styled Components 5.x 为 React Native 应用程序设置样式时,我收到警告...

Expected style "borderWidth: 2" to contain units.



must contain units warning

这在以前的版本中没有发生。

警告是什么意思?

最佳答案

在 github 上进行了一些研究和问题之后,我找到了这个......

Styled Components 使用包 css-to-react-native因为它是 React Native 转换。

css-to-react-native 最近发布的第 3 版现在要求所有测量都存在单位。 Details here .

您应该使用 px用于 React Native 的原样 density independent .

关于react-native - 为什么 styled-components 5.x 会警告 "Expected style to contain units.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58923065/

相关文章:

javascript - 如何在使用 firestore 进行本地 react 时滚动到底部时获取数据?

javascript - 在 Styled-Component 中设置嵌套组件的样式

javascript - 如何在 Next.js 的事件页面上设置链接组件的样式

html - 来自网络的图像不显示

ios - react native : Keyboard dismiss when changing focus in ScrollView

javascript - 文本节点不能是 <View> 的子节点

javascript - React Native,动态显示图像

javascript - React-redux connect 传递 Prop 太晚了

javascript - 如何在 react 样式组件中设置子组件的样式