Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
Blank screen from React Context

I am setting up firebase user authentication for a reactjs app. Everything's been working so far but when I write const {signup} = useAuth() in the file that actually renders the login page, the page turns blank.

There is a context file set up with:

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}

With my RenderPage everything is working correctly, it's just a basic JSX/HTML return function with

import {useAuth, AuthProvider} from '../Contexts/AuthContext' 
import React, { useState, useRef } from "react";

function RenderPage() {
 return( 
<AuthProvider>
<h1>Generic text</h1>
<AuthProvider>)}
export default RenderPage;

And everything works perfectly,

But then when I put in the line const {signup} = useAuth() to make it:

import {useAuth, AuthProvider} from '../Contexts/AuthContext' 
import React, { useState, useRef } from "react";

function RenderPage() {
const {signup} = useAuth()
 return( 
<AuthProvider>
<h1>Generic text</h1>
<AuthProvider>
);

The page turns blank.

Does anyone have any idea why this might be? (I already checked the firebase API key and set it up on the realtime database)

Thanks in advance

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda