import React, {useReducer} from 'react'
export default function UseReducer() {
const reducer = (state, action) => {
switch (action.type) {
case 'add':
return {count: state.count + 1};
default:
return {count: state.count};
}
}
const [state, dispatch] = useReducer(reducer, {count: 0})
const addcount = () => {
dispatch({
type: 'add'
})
}
return (
{state.count}
)
}