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
00:00
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;
Expected Output
Initially: Value: 0 Clicking '+' increments and '-' decrements the value.