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 trialTyler Mills
950 PointsShould 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?
1 Answer
Luke Robinson
728 PointsComponents 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
Steven Parker
231,184 PointsSteven Parker
231,184 PointsHi, I got your request. But I haven't taken the React courses yet myself (and have no prior experience with it) so I'll have to leave this one for someone else to answer.