1.

How to call the function in render to react?

Answer»

To call a function inside a render in React, use the FOLLOWING code:

Example

import React, { Component, PropTypes } from 'react';

export default class PatientTable extends Component {
      constructor(PROPS) {
        super(props);
        this.state = {
         checking:false
      };
        this.renderIcon = this.renderIcon.bind(this);
  }

  renderIcon(){
    console.log("came here")
    return(
      &LT;div>Function called</div>
    )
  }

  render() {

   return (
       <div CLASSNAME="patient-container">

       {this.renderIcon}      

      </div>
   );
 }
}



Discussion

No Comment Found