Build a React component that increments or decrements a number using '+' and '-' buttons.
EasyProblem Statement
Build a React component that increments or decrements a number using '+' and '-' buttons.
Sample Output
Initially: Value: 0 Clicking '+' increments and '-' decrements the value.
Limits
Time: 2s · Memory: 256 MB
Code Editor
Log in to submit00:00
Try your code in this preview. Submit marks it done.
import React, { useState } from "react"; const IncrementDecrement = () => { const [value, setValue] = useState(0); return ( <div> <p>Value: {value}</p> <button onClick={() => { // Increment the value }}>+</button> <button onClick={() => { // Decrement the value }}>-</button> </div> ); }; export default IncrementDecrement;