I'm a javascript newbie and I'm trying to figure out why this import statement fails. I don't know if this is relevant but I'm doing this in the context of a Create React app with its default webpack setup. I have these files:
TestClass.js
export default class TestClass {
sayHello() {
console.log("Hello World.");
}
}
TestModule.js
import TestClass from "./TestClass";
module.exports = {
MyExport: {
doSomething: function() {
let testClass = new TestClass();
testClass.sayHello();
}
}
}
And then my main React Application file, App.js:
import React, { Component } from "react";
import "./App.css";
import { MyExport } from "./TestModule"
class App extends Component {
constructor(props) {
super(props);
MyExport.doSomething();
... bla bla bla ...
}
When I attempt to run this in Node.js, it returns
Failed to compile.
./src/App.js
Attempted import error: 'MyExport' is not exported from './TestModule'.
What am I doing wrong?