Estoy configurando la autenticación de usuario de firebase para una aplicación reactjs. Todo ha estado funcionando hasta ahora, pero cuando escribo const {signup} = useAuth() en el archivo que realmente representa la página de inicio de sesión, la página se vuelve en blanco.
Hay un archivo de contexto configurado con:
import React, { useContext, useState, useEffect} from 'react' import {auth} from '../firebase' const AuthContext = React.createContext() function useAuth() { return useContext(AuthContext) } function AuthProvider({children}) { const[currentUser, setCurrentUser]= useState() function signup(email, password) { return auth.createUserWithEmailAndPassword(email,password) } useEffect(() => { const unsubscribe = auth.onAuthStateChanged(user => { setCurrentUser(user) }) return unsubscribe },[]); const value = { currentUser, signup } return ( <AuthContext.Provider value={value}> {children} </AuthContext.Provider> ) } export {useAuth, AuthProvider}Con mi RenderPage todo funciona correctamente, es solo una función básica de retorno JSX/HTML con
import {useAuth, AuthProvider} from '../Contexts/AuthContext' import React, { useState, useRef } from "react"; function RenderPage() { return( <AuthProvider> <h1>Generic text</h1> <AuthProvider>)} export default RenderPage;Y todo funciona perfectamente,
Pero luego, cuando pongo la línea const {signup} = useAuth() para hacerlo:
import {useAuth, AuthProvider} from '../Contexts/AuthContext' import React, { useState, useRef } from "react"; function RenderPage() { const {signup} = useAuth() return( <AuthProvider> <h1>Generic text</h1> <AuthProvider> );La página se vuelve en blanco.
¿Alguien tiene alguna idea de por qué puede ser esto? (Ya verifiqué la clave API de firebase y la configuré en la base de datos en tiempo real)
Gracias por adelantado