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 One Solution

Joseph Turner
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Turner
Full Stack JavaScript Techdegree Graduate 16,794 Points

Why not directly access planets from PlanetList, instead of passing planets as a prop into PlanetList?

The video has planets passed into the PlanetList component in the render() method. However, is there a need to do this? My code was fine with just accessing planets directly within the PlanetList component, without passing any props to PlanetList. Is it better practice to do one way or the other? Thank you in advance

1 Answer

In this specific case it wouldn't matter much, but it's good practice to use props.

When props change, it will fire an event, which causes the component to rerender to reflect the changes. Having a regular variable won't cause a rerender.