I created a store with a register/signin page and I got a dispatch error that says I imported or exported the dispatch wrong. I tried fixing it the import but I still can fix the problem.
import axios from 'axios';
import { Store } from '../utils/Store';
const { state, dispatch } = useContext(Store);
const { userInfo } = state;
const submitHandler = async ({ name, email, password, confirmPassword }) => {
closeSnackbar();
if (password !== confirmPassword) {
enqueueSnackbar("Passwords don't match", { variant: 'error' });
return;
}
try {
const { data } = await axios.post('/api/users/register', {
name,
email,
password,
});
console.log(data)
dispatch({ type: 'USER_LOGIN', payload: data });
console.log(dispatch())
};
The dispatch give me the above error and I do not know how to solve it.