`import "../App.css";
import { useReducer } from "react";
const reducer = (state, action) => {
switch (action.type) {
case "increment":
return { count: state.count + 1 };
case "decrement":
return { count: state.count - 1 };
default:
throw new Error();
}
};
const ReducerComp = () => {
const initialState = { count: 0 };
const [state, dispatch] = useReducer(reducer, initialState);
return (
<div className="flex flex-row border p-5 items-center gap-5 justify-center">
<button onClick={() => dispatch({ type: "increment" })}>+</button>