The react dynamic setting disabled property does not take effect in Safari

render(){
     var disabled=false;
     
     !this.state.beginTime?(disabled=true):(disabled=false) 
     
     return <button disabled={disabled}></button>
}

according to the change of beginTime, set the diasbled property dynamically
this code works well in chrome and Firefox, but it doesn"t work and doesn"t report an error in Safari. The version of Safari is 11.1.2.

May.25,2021

What do you mean

doesn't work? Does it have a value of false, or a value of true but no disabled effect?

in addition, your code is not very good, you can write it like this:

render(){
     <button disabled={!this.state.beginTime}></button>
}
Don't you need return in

render?


the problem has been solved.
there is no problem with this way of writing, but the time format processed by new Date is not compatible in safari, so the relevant value is always undefined, so the disabled attribute does not take effect.

Menu