为什么 styled-components 5.x 会警告“包含单位的预期样式”。

Gol*_*Jer 11 react-native styled-components

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

包含单位的预期样式“borderWidth:2”。

必须包含单位警告

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

警告是什么意思?

Gol*_*Jer 13

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

Styled Components 使用包css-to-react-native来进行 React Native 转换。

css-to-react-native 最近发布的第 3 版现在要求所有测量都存在单位。详情请看这里。

您应该使用pxReact Native,因为它与密度无关。