2021年3月20日星期六

How can I add conditions to my input in react?

Take a look at this example.

export const Foo = () => {    const [state, setState] = useState(0)    return (      <div>        <input type="button" value="" {state === 0 ? disabled : ""}/>      </div>    )  }  

I'm trying to make the button disabled if state is equal to 0 and if not then the button will not be disabled. I don't know what is wrong and why it gives me this error: '...' expected

https://stackoverflow.com/questions/66726468/how-can-i-add-conditions-to-my-input-in-react March 21, 2021 at 05:04AM

没有评论:

发表评论