title: Returning a variable from react functional component
body: <p>I have a react component as :</p>
  
  <pre><code>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
      );
    }
  }
  </code></pre>
  
  <p>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,</p>
  
  <pre><code>var moduleCode = this.getModuleCode(module);
  </code></pre>
  
  <p>it returns an undefined object. What is the correct way of returning a value from a function?</p>