Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
React initial state delay

I have a React project and I am fetching data from firebase directly on the client side. For the components that are using an initial state (which is usually set from firestore data), there is like 1 second delay on the component until the data is visible. For example, I have a paragraph "Welcome {username}". Username is being set in the useEffect by calling a function that fetches data from firestore. At first it appears blank and after 1 second, let's say, the username is visible. Is there anything I can do to fix this? I know it is due to the setState, but I am wondering if there is any fix.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I think that what you are looking for is not a fix, but a way to display things once they've been loaded.

What I would suggest is a conditional display. Something like :

  const [username, setUsername] = useState(null);

  useEffect(() => {
    yourMethodThatSetUsername();
  }, [])

  return (
    {
      username ? <YourComponent /> : null
    }
  )
about 4 years ago · Juan Pablo Isaza Denunciar

0

Usually you set a state in the component from which you are calling useEffect, like this:

[loading, setLoading] = useState(true);

You can then conditionally render your component like this: loading ? //some progress component : Welcome ${username};

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda