如果你添加styled-components
对于您的 React Native 项目,有一个专门用于本机组件的子目录:
import styled from 'styled-components/native`;
export const Container = styled.View`
...
`;
如果您尝试在 React Native TypeScript 项目中执行此操作,您将遇到以下打字错误:
Could not find a declaration file for module 'styled-components/native'.
解决此问题的典型方法是安装@types/styled-components
模块在您的开发依赖项中,但这并不能解决问题。
https://github.com/styled-components/styled-components/issues/2099#issuecomment-749776524 https://github.com/styled-components/styled-components/issues/2099#issuecomment-749776524
The styled-components/native
类型移至@types/styled-components-react-native
.
所以,要解决:
npm install --save-dev @types/styled-components-react-native
or
yarn add -D @types/styled-components-react-native
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)