153k views
2 votes
If you want to import just the Component from the React library, what syntax do you use?

User ManuQiao
by
8.2k points

1 Answer

4 votes

Final answer:

To import only the Component from the React library, use the ES6 named import syntax: import { Component } from 'react';. This helps optimize the bundle size by including only what is necessary.

Step-by-step explanation:

To import just the Component from the React library, you would use the following syntax:

import { Component } from 'react';

This line of code uses ES6 module import syntax to import only the Component class from the React library rather than the entire library. This approach is known as named import, which is useful for optimizing your application's bundle size by including only the parts of the library that you need.

User Frabcus
by
8.0k points