Let's say we have these 2 classes, What are the differences of having a function in the module scope vs being a static class function, assuming doSomething doesn't require the this access. the only difference I can see is, module is "more private", is there any thing else?
Sample1.js
class Sample1 extends React.Component {
static doSomething(input) {
// ...
return input2;
}
render() {
if (Sample1.doSomething(x)) {
return <div />;
}
return null;
}
}
export { Sample1 };
Sample2.js
const doSomething = (input) => {
// ...
return input2;
};
class Sample2 extends React.Component {
render() {
if (doSomething(x)) {
return <div />;
}
return null;
}
}
export { Sample2 };