I've been learning some React, and I have been using ES6 classes to write my class-based components. I'm working on a little Node project, and none of this syntax is working.
class Handler {
handleReq = () => {
this.ctx = ctx;
};
testFunc = async () => {
};
}
export default (HandleReq = Handler.prototype.handleReq);
What is wrong with this syntax? Does it not run in Node? I had to install esm to get the import/export syntax working correctly, but this still fails to compile.
Handler.prototype.handleReqwill never work, ashandleReqhas to be bound to an instance, therefore it will only exist on an instance ((new Handler).handleReq)classmethods or put the arrow functions in the constructor where they belong. You don't seem to have posted your complete code, but I doubt you need arrow functions here at all.export default (HandleReq = Handler.prototype.handleReq);supposed to accomplish? Apart from throwing an exception on assignment of an undeclared global variable, why are you even using aclassif all you ever export is a single method?