Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

371
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!