Hooking Up Dispatch

Okay, asking our users to install the developer tools and dispatch actions by hands seems not great. Maybe we should get those buttons working?

In order to do that, we're going to need them to start dispatching some actions.

const dispatch = useDispatch();

This is store.dispatch from our store.

Let's import our action creators.

import { decrement, increment, set } from "./actions";

And now we can dispatch those action creators.

<button onClick={() => dispatch(increment())}>Increment</button>
<button onClick={() => dispatch(set(0))}>Reset</button>
<button onClick={() => dispatch(decrement())}>Decrement</button>