Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Brandon Zucker
Brandon Zucker
11,451 Points

Syntax Error, but cannot find where! Adjacent JSX elements must be wrapped in an enclosing tag

Hi Below is my code, it continues to tell me I need to wrap elements in closing tags. I feel like im not stupid and have exactly the same amount of closing as opening tags.... Can anyone find the error in this code?

function Application() { return ( <div className="scoreboard"> <div className="header"> <h1>Scoreboard</h1> </div> </div> <div className="players"> <div className="player"> <div className="player-name"> Brandon Zucker </div> <div className="player-score"> <div className="counter"> <button className="counter-action decrement"> - </button> <div className="counter-score"> 33 </div> <button className="counter-action increment"> + </button> </div> </div> </div> </div> ); };

ReactDOM.render(<Application />, document.getElementById('container'));

1 Answer

you are returning multiple elements instead of just one. wrap everything in your return in a div, the error will go away. see this: https://stackoverflow.com/questions/34893506/return-multiple-elements-inside-react-render