Подскажите пожалуйста почему в Next 13 такая ошибка:
Unhandled Runtime Error
Error: 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
https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Source
src\services\register.tsx (7:28) @ state
5 |
6 | const RegisterService = () => {
> 7 | const email = useSelector(state => state.email)
| ^
8 | const password = useSelector(state => state.password)
9 |
10 | createUserWithEmailAndPassword(auth, email, password)
Вот код:
"use client"
import { createUserWithEmailAndPassword } from "firebase/auth";
import {auth} from '../firebase/firebase'
import {useSelector} from "react-redux";
const RegisterService = () => {
const email = useSelector(state => state.email)
const password = useSelector(state => state.password)
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// ..
});
}
export default RegisterService