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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![travis halarewich](https://secure.gravatar.com/avatar/2db88425493c3bbaebc891850b0968cf?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
travis halarewich
9,165 PointsWill not render to web browser
With the code below I can not get it to render to the webpage. The only thing i've noticed is the code snippet
ReactDOM.render()
when looking at render() in workspace it is not have the proper syntax highlighting like it should. This leads me to believe there is something before it causing an issue for render() not to be recognized in turn not allowing it to show up in the browser.
// =============================================================
// WRITE YOUR CODE BELOW
// =============================================================
// 1: Create a 'Planet' component that renders a planet card
const Planet = (props)=> {
return (
<div className="card">
<div><img src={props.img} alt={props.name}/></div>
<h2>{props.name}</h2>
<p>{props.desc}</p>
<h3>Planet Profile</h3>
<ul>
<li><strong>Diameter:</strong>{props.diameter}</li>
<li><strong>Moons:</strong>{props.moons}</li>
</ul>
</div>
);
}
// 2: Create a container component that iterates over the planets array
// and renders a 'Planet' component for each object in the array
const Container = (props)=> {
return (
<div className="container">
props.planets.map( planet=>
<Planet
key={planet.id}
name={planet.name}
diameter={planet.diameter}
moons={planet.moons}
desc={planet.desc}
img={planet.url}
/>
)
);
}
// 3: Render the container component to the DOM
ReactDOM.render(
<Container planets={planets}/>, document.getElementById('root')
)
1 Answer
![Ryan Beck](https://secure.gravatar.com/avatar/9ea1a7fda21fb9863ab4d32110b3b9f6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ryan Beck
3,736 PointsHi, you're missing the curly brackets for the iterator in the container component (javascript expressions must be enclosed in curly brackets). Also, the div tag needs to be closed.
It should look something like this.
const Container = (props)=> {
return (
<div className="container">
{props.planets.map( planet=>
<Planet
key={planet.id}
name={planet.name}
diameter={planet.diameter}
moons={planet.moons}
desc={planet.desc}
img={planet.url}
/>
)}
</div>
);
}
Hope this has helped :)