class App extends React.Component {_x000D_
_x000D_
buttonClick(){_x000D_
console.log("came here")_x000D_
_x000D_
}_x000D_
_x000D_
subComponent() {_x000D_
return (<div>Hello World</div>);_x000D_
}_x000D_
_x000D_
render() {_x000D_
return ( _x000D_
<div className="patient-container">_x000D_
<button onClick={this.buttonClick.bind(this)}>Click me</button>_x000D_
{this.subComponent()}_x000D_
</div>_x000D_
)_x000D_
}_x000D_
_x000D_
_x000D_
_x000D_
}_x000D_
_x000D_
ReactDOM.render(<App/>, document.getElementById('app'));
_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>_x000D_
<div id="app"></div>
_x000D_
it depends on your need, u can use either this.renderIcon()
or bind this.renderIcon.bind(this)
UPDATE
This is how you call a method outside the render.
buttonClick(){
console.log("came here")
}
render() {
return (
<div className="patient-container">
<button onClick={this.buttonClick.bind(this)}>Click me</button>
</div>
);
}
The recommended way is to write a separate component and import it.