5

Bear with me, I am just starting to explore Next.js ... I couldnt find any info on this error I got from using the html tag two times. It works with just one container, but as soon as I add another one, I get this:

Error: error: Unexpected token "div". Expected jsx identifier

Juno
  • 211
  • 5
  • 17
  • 2
    Can you provid the code please ? – Tom Dec 28 '21 at 15:54
  • 1
    Does this answer your question? [Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag](https://stackoverflow.com/questions/31284169/parse-error-adjacent-jsx-elements-must-be-wrapped-in-an-enclosing-tag) – juliomalves Dec 28 '21 at 22:55
  • @Tom it's exactly what Benjamin Carlson expected ;) – Juno Dec 28 '21 at 23:10
  • One of the quicker/more obvious causes is where you some kind of syntax error in the markup you are returning – söze Mar 08 '23 at 21:35

1 Answers1

8

This is because you are trying to pass 2 children but Next.js only expects one. I believe you are doing something like this:

return (
    <div>div 1</div>
    <div>another div</div>
)

Instead you need to wrap both of these with another tag:

return (
<>
    <div>div 1</div>
    <div>another div</div>
</>
)
Benjamin Carlson
  • 295
  • 3
  • 13