K
K
Koopengagen2022-02-02 10:31:46
React
Koopengagen, 2022-02-02 10:31:46

What is the best way to import react?

What is the best way to import react? Through * or prescribe the components used?

If you import via *, then when you build the project, does the react import only the used components or all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shipin, 2022-02-02
@Koopengagen

There is an article about this on Habré
In the general case, as you prefer, import it.
Afraid of getting confused or losing the connection (there are packages with similar components in libraries), then import via *
If you are sure that there will be no other libraries, then import only certain components
In any of the cases, React imports only the components that are needed here and now.
Addendum:
Optimization will suffer, and here it will depend on the number of imported components. Information is here about optimization , and general information is here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question