javascript nested function call in reactjs render classname -
function inside render statement not working. how call function part of classname? this._displaylogic().showatraffic()
returning undefined.
expected result: classname ="up blue"
,
current result: "up " , an error in console.
class linestatus extends react.component{ constructor(props){ super(props); } _displaylogic=()=>{ var showatraffic=()=>{ return "blue"; }; var showbtraffic=()=>{ return "yellow"; }; console.log(showatraffic()+"....."); //this works. } componentwillmount(){ this._displaylogic(); } render(){ return( <div classname="status-content collapse" key={this.props.key}> <div classname={"up "+this._displaylogic().showatraffic()}> <row classname="show-grid"> <span>approval</span> </row> <row classname="status-subcontent collapse"> line content goes here. </row> </div> ) } }
_displaylogic
should return object when invoked e.g.
_displaylogic=()=>{ var showatraffic = () => 'blue' var showbtraffic = () => 'yellow' return {showatraffic, showbtraffic}; }
Comments
Post a Comment