Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

379
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda