Search code examples
reactjsvisual-studio-codeformathighlight

Used the reactjs in vscode was report an error


use "jsx" grammar in visual studio code. visual studio code report an error

enter image description here

Please help me. Thanks!!!


Solution

  • The symbol "<" should appear in the same line with the tag name.

    For example, instead of doing that:

       return (     <
          button className="square"> {/*TODO*/} <
          /button>
       )
    

    Do that:

      return(
        <button className="square"> 
             {/*TODO*/}
        </button>
    )
    

    If you want to split the tag to multiple lines, you can do it like that:

          return (
            <button 
              className="square"
              id="id"
              onClick={someFunc}
            > 
                 {/*TODO*/}
            </button>
           )