New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S2786: 'View' cannot be used as a JSX component. #15802
Comments
seems the error was from ts, not eslint? |
This error is coming from TypeScript, not ESLint. Maybe these recent discussions could be helpful: DefinitelyTyped/DefinitelyTyped#59839 https://stackoverflow.com/questions/71831601/ts2786-component-cannot-be-used-as-a-jsx-component |
I'm facing the same issue about this error. I add the below code to my package.json file.
Then, Run It works for me. |
i have the same issue, not really an error, but make me confuse! |
I have the same problem |
Same |
I had to just make sure the version numbers for: match with: |
|
For me the issue was I was importing types explicitly when not needed:
|
I added the following dependencies and it solved the problem: "@types/react-dom": "17.0.14",
"@types/react": "~18.0.0",
"@types/react-native": "~0.69.1", |
It solved my problem, thank you. |
for me there was wrong version of type script solved the issue |
To add more to this specific topic, I was having this problem with every React Native Built-In Component (like View, ScrollView, TouchableOpacity, etc.);
for me what solved was @GtechHardik below suggestion:
|
Perfect solution! Thanks! |
Environment
Node version: v14.17.5
npm version: v7.21.1
Local ESLint version: v8.14.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 21.1.0
What parser are you using?
@typescript-eslint/parser
What did you do?
Configuration
What did you expect to happen?
Working eslint configuration
What actually happened?
TS2786: 'View' cannot be used as a JSX component. Its instance type 'View' is not a valid JSX element. The types returned by 'render()' are incompatible between these types. Type 'import("/Users/mikhailkiselyov/WebstormProjects/publife/node_modules/@types/react-native/node_modules/@types/react/index").ReactNode' is not assignable to type 'React.ReactNode'. Type '{}' is not assignable to type 'ReactNode'.
Participation
Additional comments
No response
The text was updated successfully, but these errors were encountered: