Tuesday, July 20, 2021

[Next.js][Resolved] jsx element 'html' has no corresponding closing tag

I meet a error message that "jsx element 'html' has no corresponding closing tag", 

here is my source code:

 const Template = ({ children, title }) => {

  return 

    <html>

    <head>

    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>testing</title>

    <link rel="stylesheet" href="/style.css">

    </head>

    </html>

}

export default Template;


Thanks for Crob from stackovrflow for the answer: 

If tag is not a pair, add / around the second last character to close the tag.

However i found it's not related to the tag "html", this msg may mean there is a pair of problem tag inside html tag.


So the correction is :

const Template = ({ children, title }) => {

  return 

    <html>

    <head>

    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>testing</title>

    <link rel="stylesheet" href="/style.css" />

    </head>

    </html>

}

export default Template;


Reference:

https://stackoverflow.com/questions/30852751/expected-corresponding-jsx-closing-tag-for-input-reactjs


No comments :

Post a Comment