What i'm doing is creating an authentication system with react hooks. However, when I declare and call a constant using a react component it returns the error below. What is the right place to declare a constant and / or a function?
Error: React Hook "useDispatch" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function
function handleSubmit({email, password}) {
dispatch(signInRequest(email, password));
}
const dispatch = useDispatch();
class Login extends React.Component {
render() {
return (
<>
//Other code here
</>
);
}
}
export default Login;