Programming Exercises

Create a button that disables itself after being clicked once.

Easy

Problem Statement

Create a button that disables itself after being clicked once.

Sample Output

The button text changes to 'Clicked!' and the button becomes disabled.

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React, { useState } from "react"; const DisableButton = () => { const [isDisabled, setIsDisabled] = useState(false); return ( <button disabled={isDisabled} onClick={() => { // Disable the button and update the text }} > Click Me </button> ); }; export default DisableButton;
Log in or sign up to run or submit your code.Log inSign up
Expected Output
The button text changes to 'Clicked!' and the button becomes disabled.