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 trialAshish Mehra
3,407 PointsAdjacent JSX elements must be wrapped in an enclosing tag
function Application(){
return(
<h1>Users Table</h1>
<form>
<input type="text" />
<input type="submit" value="+" />
</form>
<div id="users">
<li className="user">Ashish Mehra <button>Edit</button><button>Delete</button></li>
<li className="user">Ashish Mehra <button>Edit</button><button>Delete</button></li>
<li className="user">Ashish Mehra <button>Edit</button><button>Delete</button></li>
</div>
);
}
ReactDOM.render(<Application />,document.getElementById('container'));
I tried to wrap form in div but it doesn't seem to work for me...
1 Answer
andren
28,558 PointsWhen using JSX you can only return a single element. In your solution there are three elements (h1, form and div) that are adjacent to each other. The way to solve this is to wrap all of them in a div like this:
function Application(){
return(
<div>
<h1>Users Table</h1>
<form>
<input type="text" />
<input type="submit" value="+" />
</form>
<div id="users">
<li className="user">Ashish Mehra <button>Edit</button><button>Delete</button></li>
<li className="user">Ashish Mehra <button>Edit</button><button>Delete</button></li>
<li className="user">Ashish Mehra <button>Edit</button><button>Delete</button></li>
</div>
</div>
);
}
Ashish Mehra
3,407 PointsAshish Mehra
3,407 PointsThanks I forget this ;-p