In my React project (w/ Webpack), my folder structure is as follows:
├── myfile.js
├── Report
├── index.js
Based on my research, I should be able to import the Report
module in myfile.js
thus:
import { Report } from './Report';
But that doesn't work. I got the error:
Attempted import error: 'Report' is not exported from './Report'.
This does, however.
import { Report } from './Report/index';
My Report/index.js
has the following export:
// export default class Report extends Component { // this was a typo
export class Report extends Component {
// etc
}
How can I solve this or at least troubleshoot it?
By the way, I originally used default export/import, but I changed to a named one in hope that it would make a difference. It doesn't.
Update. I'm really sorry, but this post originally and mistakenly had export default
in index.js
. That is not what is actually in the file, and it might have led some of the answerers down the wrong path. I did change that to just export
when I changed the import from import Report
to import { Report }
as I said above. So the import and export should have matched in either case (named or default), and neither worked.