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
.
I am aware that I can check this.state directly in handler
instead I am looking for a solution to be implemented inside render
.
...
handler(){
}
render() {
const { canClick} = this.state
return (
<div onClick={this.handler}>hello</div>
)
}
...