使用了一段时间的反应,但新的反应本地人。
我使用的是顺风和https://tailwindcss-react-native.vercel.app/installation
import { View, Text } from "react-native";
import React from "react";
export default function Navigation() {
return (
<View className="grid h-screen w-screen place-items-center">
<Text className="text-red-800">Test</Text>
</View>
);
}
“顺风作案”,文本是红色的,但是我在^^的类名下得到了TS错误。
No overload matches this call.
Overload 1 of 2, '(props: ViewProps | Readonly<ViewProps>): View', gave the following error.
Type '{ children: Element; className: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<View> & Readonly<ViewProps> & Readonly<{ children?: ReactNode; }>'.
Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<View> & Readonly<ViewProps> & Readonly<{ children?: ReactNode; }>'.
Overload 2 of 2, '(props: ViewProps, context: any): View', gave the following error.
Type '{ children: Element; className: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<View> & Readonly<ViewProps> & Readonly<{ children?: ReactNode; }>'.
Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Text> & Readonly<TextProps> & Readonly<{ children?: ReactNode; }>'.ts(2769)
我已经跟踪了世博类型记录的设置,我的tsconfig看起来如下:
{
"compilerOptions": {},
"extends": "expo/tsconfig.base"
}
发布于 2022-07-22 08:44:40
默认情况下,尾风响应本机快速启动设置不包括对TypeScript的支持。然而,文档提到了如何添加它:
创建一个文件(如。src/tailwindcss react native.d.ts)并粘贴这一行
import "tailwindcss-react-native/types.d";
包含此文件后,TypeScript错误将消失。
发布于 2022-10-19 13:03:25
我也遇到过同样的问题,包含这些类型的最简单的修复方法是创建一个新的app.d.ts
文件,并添加一个引用以下类型的三元斜杠指令:
/// <reference types="nativewind/types" />
如果这不能解决您的问题,为了消除红线,您可以在文件的顶部添加@ts-nocheck
。(免责声明,此解决方案不能解决问题,只需通过禁用TS检查特定文件来获取警告区域)
发布于 2022-07-08 11:17:22
React本机View
和Text
组件不接受className
支持,只接受style
。
https://stackoverflow.com/questions/72909992
复制相似问题