'React import multiple components from a folder
I am trying to import 2 components from the components folder. Both components' class are export default .
However, I got an error message that I should use the curly braces in my import statement. However, both components above are not using named export so curly braces is not needed when importing them.
Why isn't it working? How can I make this work?
Solution 1:[1]
You can create an index.js file in the components folder that imports and exports all the components, then you will be able to import the components at the same line.
This question and answer might help you, and the special part is it can performs both import and export using only one single line of code.
Solution 2:[2]
Try importing them individually:
import Login from "./components/Login"
import Question from "./components/Question"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chong Onn Keat |
| Solution 2 | casimirth |


