React Syntax Error : Expected corresponding JSX closing tag for

后端 未结 3 625
不知归路
不知归路 2021-01-02 02:13

I\'m beginner in React and I try to do a \"Camper Leader Board\" project from FreeCodeCamp. In StackOverflow code snippet it throws me:
` \"message\": \"SyntaxError:

相关标签:
3条回答
  • 2021-01-02 02:23

    You need to close your img tag with a closing />:

    <img src={this.props.user.img} alt="logo" />
    

    JSX is not as lenient as HTML when it comes to properly closing tags.

    0 讨论(0)
  • 2021-01-02 02:30

    As the error explain itself you need to close the image tag in camper component.

    <td>
        <img src = {this.props.user.img} alt="logo" />{this.props.user.userName}
    </td >
    

    This should work.

    0 讨论(0)
  • 2021-01-02 02:33

    The message returned by the compiler is telling you there is no closing tag for the img element. JSX isn't the same as html.

    <img src = {this.props.user.img} alt="logo"></img>
    

    or

    <img src = {this.props.user.img} alt="logo" />
    
    0 讨论(0)
提交回复
热议问题