Can you import multiple objects from a library at once?


In the context of this exercise, can you import multiple objects from a library at once?


Yes, you can do this using “unpacking” when importing from a library.

For example, say that you wanted to import multiple functions from some library, you could do so as follows,

import { functionA, functionB, functionC } from 'library';

Another, more concrete, example is importing objects from the ‘react-router’ library.

import { Router, Switch } from 'react-router';

As in the exercise we are not mentioning which functions to import, doesn’t that import all the functions from react library?


Do we have to maintain a strict name of ‘React’ for the variable or can we use any name?


See the following:

If you’re using the JS import method then you have to use the name ‘React’. If you want to use an alias then you have to write something like:

import { functionA as funcA } from ‘library’;


Actually, we are mentioning which part of the library to import when we write:

import React from 'react';

This code imports the React object of the react library. But, wait! There’s no curly braces in it. Then, it’s actually about the type of the export.

It can be read further from:


Yes, you can import multiple objects from a library.

import React , {Component} from “react”

1 Like

What I find wild about this is: Literally the Animal Fun Fact project literally has you doing this step 1 importing both React and React DOM and now they’re re-introducing it??? Maybe this ought to have been earlier on in the course? Especially if this is your first do around on language learning …