I would like to know if it is possible to set onClick on a div element in react based on the value of a property in my case canClick.
onClick
canClick
I am awar
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 ( Click ) } } ReactDOM.render(, document.body);