'every first react-native component gets typescript error
When I use the Text component of react-native, I get this error:
No overload matches this call.
Overload 1 of 2, '(props: TextProps | Readonly<TextProps>): Text', gave the following error.
Type '{ children: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<Text> & Readonly<TextProps>'.
Overload 2 of 2, '(props: TextProps, context: any): Text', gave the following error.
Type '{ children: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<Text> & Readonly<TextProps>'.ts(2769)
My code:
// .tsx file
import {Text} from 'react-native'
...
<Text>123</Text>
tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"declaration": true,
"target": "esnext",
"module": "esnext",
"sourceMap": true,
"experimentalDecorators": true,
"jsx": "react-native",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"strict": false,
"skipLibCheck": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"@assets/*": [
"src/assets/*"
],
"@config/*": [
"src/config/*"
],
"@src/*": [
"src/*"
],
"react-native": [
"node_modules/@mrn/react-native"
]
}
}
}
when I move the mouse on "Text" component, I get this error, and I can not solve it, sad
No overload matches this call.
Overload 1 of 2, '(props: TextProps | Readonly<TextProps>): Text', gave the following error.
Type '{ children: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<Text> & Readonly<TextProps>'.
Overload 2 of 2, '(props: TextProps, context: any): Text', gave the following error.
Type '{ children: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<Text> & Readonly<TextProps>'.ts(2769)
The "Text" component is import from react-native and Text is an official component.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|