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 trialJonathan Grieve
Treehouse Moderator 91,253 PointsImports in React Projects
One of the most intimidating things I find about starting a project in React is knowing or remembering which imports you need to make in a react project and how they're actually formatted.
I know that this usually comes with practice and the error messages should be a good guide for us but I wonder if there's a definitive documentation or a list that can help us with this?
1 Answer
Michael Chi
8,330 PointsPlease correct me if I am wrong. But out of all the react projects I have seen, mostly you need to import React and Components from react.
import React, { Component } from 'react'
I think these 2 will allow you to start building basic apps.
All other imports are either some external node modules you have installed, which you have to look at their own documentation on usage or some refactored customized components that you created yourself.
You can check out the official documentation on React by Facebook for more info. I am speaking from experience as I haven't found any other good documentations. But please correct me if there are better documentations found.
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Michael,
Thanks for responding, I knew someone would pick it up eventually :D
So yes, for basic projects you start with the basic imports for getting React itself hooked up and one import for each component. But beyond that, all I see is a whole load of import statements for me to get my head around, and I just think, am I thinking about this the wrong way; trying to remember a bunch of stuff instead of just how to find them?
Thanks
Cole Trumbo
195 PointsCole Trumbo
195 PointsSame. Did you ever end up finding an easy way to make sense of them all? and/or some sort of a cheat sheet? Currently I'm taking some extra time to learn npm and Node better to see if that helps. But it might have a lot more to do with Webpack.