ReactNative
[ React Native ] VScode cannot use JSX unless the '--jsx' flag is provided
좋은개발자가되고싶다
2023. 6. 4. 22:48
728x90
반응형
VScode로 코딩을 치고있는데, 자꾸 jsx return 컴포넌트 들에 붉은 에러 줄이 표시됐다.
물론 컴파일엔 문제가 없어서 vsCode문제겠거니 하고있었는데,
그냥 눈이 편하게 하기위해 붉은 에러줄을 없애기로 했다.
tsconfig.json 에 가보니
{
"extends": "@tsconfig/react-native/tsconfig.json",
}
덩그러니 한줄만 있었고, 붉은 줄이 표시되고있었다.
해당 key-value의 에러 메세지는 file '@tsconfig/react-native/tsconfig.json' not found.
이었고,
"jsx": "react-jsx"
를 밑에 추가해주니,
'jsx' should be set inside the compilerOptions 라는 붉은 줄이 나왔다.
tsconfig.json을
{
"extends": "@tsconfig/react-native/tsconfig.json",
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"jsx": "react"
}
}
로 수정해주고
VScode를 재시작하니 해결
728x90
반응형