Create a counter component using useReducer with increment, decrement, and reset actions.
MediumProblem Statement
Create a counter component using useReducer with increment, decrement, and reset actions.
Sample Input
Initial counter value: 0
Sample Output
Increment, decrement, and reset the counter.
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import React, { useReducer } from "react";
const Counter = () => {
return (
<div>
<p>Counter: 0</p>
<button>Increment</button>
<button>Decrement</button>
<button>Reset</button>
</div>
);
};
export default Counter;
Input
Initial counter value: 0
Expected Output
Increment, decrement, and reset the counter.