invalid hook call. hooks can only be called inside of the body of a function component
This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See for tips about how to debug and fix this problem.
import './Login.css'
import { Button } from '@material-ui/core';
import { login } from '../features/userSlice';
import { auth, provider } from './firebase';
import { useDispatch } from 'react-redux';
function Login() {
const dispath = useDispatch;
const signIn = () => {
auth.signInWithPopup(provider)
.then(({user}) => {
dispath(login({
displayName: user.displayName,
email: user.email,
photoUrl: user.PhotoURL,
}));
})
.catch((error) => alert(error.message));
};
return (
<div className="login">
<div className="login_container">
<img src="https://i.pinimg.com/originals/39/21/6d/39216d73519bca962bd4a01f3e8f4a4b.png" alt=""/>
<p>Sign in with google</p>
<Button variant="contained" color="primary" onClick={signIn}>Login </Button>
</div>
</div>
)
}
export default Login