I am trying to import my custom hook function(RegisterUser) on my register page. but when I am trying to import like this const { RegisterUser } = UseFirebase() I am getting an error which is const RegisterUser: any Property 'RegisterUser' does not exist on type 'readonly [(email: string, password: string, name: string, history: any) => Promise<void>]'.
This is my custom hook function.
export default function UseFirebase() {
const [user, setUser] = useState({})
const [error, setError] = useState('')
const [admin, setAdmin] = useState(false)
const [isLoading, setIsLoading] = useState(true)
const auth = getAuth()
// REGISTER WITH EMAIL AND PASSWORD
const RegisterUser = async (email: string, password: string, name: string, history: any) => {
setIsLoading(true)
const userCredential = await createUserWithEmailAndPassword(auth, email, password)
const newUser = {
email,
displayName: name
};
setUser(newUser);
setError('')
// Pass userCredential.user instead of auth.currentUser
updateProfile(userCredential.user, {
displayName: name
}).then(() => { }).catch((error) => { });
history.replace('/');
}
return [RegisterUser] as const
}
Can anyone help me, please? How can I solve the error?