Put the condition like this:
onClick={canClick ? this.handler : undefined }
Working Code:
class App extends React.Component {
_click(){
// it will not print the value
console.log('yes');
}
render(){
return (
<div>
<div onClick={false ? this._click : undefined }>Click</div>
</div>
)
}
}
ReactDOM.render(<App />, document.body);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>