Answers for "disable button in jsx"

0

disable a button react

// Input field listens to change, updates React's state and re-renders the component.
<input onChange={e => this.setState({ value: e.target.value })} value={this.state.value} />

// Button is disabled when input state is empty.
<button disabled={!this.state.value} />
Posted by: Guest on May-02-2020
0

disable button in jsx

const buttonRef = useRef();

const disableButton = () =>{
  buttonRef.current.disabled = true; // this disables the button
 }

<button
className="btn btn-primary mt-2"
ref={buttonRef}
onClick={disableButton}
>
    Add
</button>
Posted by: Guest on October-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language