Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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} />
Comment

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>
Comment

DisableButton in React js

import {useRef} from 'react';
let btnRef = useRef();

const onBtnClick = e => {
  if(btnRef.current){
    btnRef.current.setAttribute("disabled", "disabled");
  }
}

<button ref={btnRef} onClick={onBtnClick}>Send</button>
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native image auto height 
Javascript :: ajax with progress bar 
Javascript :: change node version 
Javascript :: union of two arrays javascript 
Javascript :: days difference in moment js 
Javascript :: check local storage javascript 
Javascript :: add value to each object in array javascript 
Javascript :: ionic capacitor keyboard push content up 
Javascript :: how to delete element in array in javascript 
Javascript :: local storege in jquery 
Javascript :: how to add up all the numbers in between 0 and that number 
Javascript :: text field material ui max input for number 
Javascript :: nodejs how to send html 
Javascript :: js addeventlistener arrow keys 
Javascript :: boolean constructor js 
Javascript :: Cookies In NodeJS 
Javascript :: javascript group by key 
Javascript :: express req body undefined 
Javascript :: jquery upload image 
Javascript :: localdatetime json 
Javascript :: react text input onchange 
Javascript :: js to uppercase 
Javascript :: js create json array 
Javascript :: jquery check if input is empty 
Javascript :: process.stdin.on("data", function (input) { _input += input; }); 
Javascript :: js set canvas size 
Javascript :: jquery change tabs 
Javascript :: javascript split sentence into words 
Javascript :: import svg react 
Javascript :: npm add latest version to package json 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =