Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

387
Visualizações
How to find out module import instructions when not in the docs?

Often in documentation for libraries, information will be given in the docs about how to import the module once it's been installed via npm. For example:

import React from "react" 

When this isn't given, how is it possible to know what should be imported to make use of the library?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

For almost all libraries / packages, the package name is the one that you need to import.

For example, you run npm install react to install react into your project folder.

Notice how you wrote react while executing the command. This tells us that you installed a package called react.

Now to import it, you simply write:

import the_name_you_want_to_declare from 'the_package_name';

Now this syntax is only when the package has default exports.

For packages that don't have default exports, you should write:

import {the_named_export} from 'the_package_name';

Notice the curly braces around the declaration name to be used in that file.

about 4 years ago · Juan Pablo Isaza Relatório

0

Projects setup with Modern frameworks like react, vue, angular come with built in build tool like webpack. It takes care of dependency tree of the project and only load necessary modules.

ex: Import { flatten } from lodash:

Above statement only includes flatten method in your bundle instead of whole lodash.

Regarding your question of what to import depends upon what's already installed and what exactly do you want to use.

Hope that clarifies.

about 4 years ago · Juan Pablo Isaza Relatório

0

For default imports (like the one you showed) you can choose any name you like.

For named exports you're going to have to dig into the source code to see which named exports exist. If a package doesn't even provide documentation on that, I wouldn't consider using it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda