I want to perform a dispatch on the state items only when the component has been unmounted. So I tried this:
const dispatch = useDispatch();