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
Log in to submit00:00
Try your code in this preview. Submit marks it done.
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;