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!
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
Should each React component be responsible for making the API calls for the data it requires?
I'm building out a ReactJS app that will have its data provided via a RESTful API.
Should I have a single API call when the app mounts that indicates which components should load as well as provides all data (top links list, sidebar content, page content, etc..) or should the top links component make an API request for the links JSON object, and each other component do the same?
Luke Robinson728 Points
Components should be as dumb as possible, so you don't want them making their own API calls. Instead, the top level component for the page should perform the API calls, and pass the relevant data to it's children as props