Action Function

Loading "Action Function"
πŸ‘¨β€πŸ’Ό this.setState from class components can also accept a function. So let's add support for that with our simulated setState function. See if you can figure out how to make your reducer support both the object as in the last step as well as a function callback:
const [state, setState] = useReducer(countReducer, {
	count: initialCount,
})
const { count } = state
const increment = () =>
	setState((currentState) => ({ count: currentState.count + step }))
const decrement = () =>
	setState((currentState) => ({ count: currentState.count - step }))

Access Denied

You must login or register for the workshop to view and run the tests.

Check out this video to see how the test tab works.