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 React Components (2018) Build Modular Interfaces with Components Separating Class Components Into Modules

What'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
Manjila Nakarmi
7,449 Points

When 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.