Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Unexpected token. Did you mean `{'}'}` or `}`? JSX element

Tags:

reactjs

I'm getting the error:

Error: Unexpected token. Did you mean {'}'} or }? JSX element

With this code:

function CompositeCntl() {
  return (
    <div>
    <Button />
    <Display />
    <div/>
    );
}
like image 926
Jeremy Thompson Avatar asked Sep 20 '25 23:09

Jeremy Thompson


2 Answers

{<div/> }--> self-closing {<div></div>} ---> closing tag

like image 148
Soniya Rana Avatar answered Sep 22 '25 12:09

Soniya Rana


I accidentally put the slash after the closing div:

 <div/>

This is how to correct it:

function CompositeCntl() {
  return (
    <div>
    <Button />
    <Display />
    </div>
    );
}
like image 26
Jeremy Thompson Avatar answered Sep 22 '25 12:09

Jeremy Thompson