Search code examples
reactjsvisual-studio-code

React gives me red underline errors but there is no error


Visual Code gives errors in lines but there are no errors in those lines.

enter image description here


Solution

  • Please rename your file to "todo.jsx".

    Explanation:

    VSCode and other IDEs choose your parser based on the file extension. For VSCode it looks like you are creating a "normal" JavaScript file. But JavaScript does not know tags, so you get an error message.

    A small addition: if you ever work with TypeScript in React, the same applies: instead of the .ts extension you should choose the .tsx extension.