Quantcast
Channel: Unable to import directory in React - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Unable to import directory in React

$
0
0

My file layout is as follows:

// Folder structure://    |-src//        |-util//             |-index.js//             |-PageScreen1.js//             |-PageScreen2.js (and etc...)//        |-PageScreen.js//        |-index.js

I would like to import all of util into PageScreen. At the top of PageScreen.js I put

import * as All from ./util

but this results in a module not found error. Could I get some advice on how to solve this issue?

EDIT: I've added an index.js folder as suggested in one of the answers below. Everything works if I import/export the PageScreens like

import PageScreen1 from './PageScreen1';import PageScreen2 from './PageScreen2';export {PageScreen1, PageScreen2}; 

However I have many PageScreen.js files, so is there a way to quickly import/export all of them?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images