is it okay to use useDispatch hook inside a function or a class? I am not talking about functional or class components. I want to dispatch a state change from function/class.
// Example: utils.ts
export function foo(){
const bar = getBar();
const dispatch = useDispatch();
dispatch(addBar(bar))
}