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 trialGreg G
3,884 PointsWhat's the point of using `import React, { Component }`?
I get that when you use that, you don't have to write React.Component
when defining the module class, you can just write Component
, but why is this desirable? Just seems like you're trading out having to write text on one line with being able to not have to write text on another.
Is there some deeper benefit to this that this lesson doesn't cover?
1 Answer
Manjila Nakarmi
7,449 PointsWhen writing code in a large project you don't the code to be concise and DRY . writing React.Component, again and again, will be tedious in a codebase that is huge. Instead importing the react component as Component will shorten the code and made it easier to read.
Charlie Prator
Front End Web Development Techdegree Graduate 19,854 PointsCharlie Prator
Front End Web Development Techdegree Graduate 19,854 PointsIs that really all it's for? Less characters to type?
I feel like I missed some underlying point here.