I have a react component as :
class ModulesListing extends React.Component {
render(){
const module = this.props.module;
getModuleCode(module){
var moduleCode = 0;
// Do relevant calls and get moduleCode
return moduleCode;
}
return (
//Info to display
);
}
}
Here, I need to get the value of moduleCode within return() and assign it to a variable to do further processing. when I assigned as,
var moduleCode = this.getModuleCode(module);
it returns an undefined object. What is the correct way of returning a value from a function?
const theCode = getModuleCode(module);?