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

115
Vistas
Render data from a database

Say I want to fetch someone's name from a firebase database to render in JSX for a React Native project. I want to render something as follows

return(
 <View>
   <Text>{name} retrieved data!</Text>
 </View>)

Where name is some data stored in the realtime database. To get the "name" variable, I would need to make an async call to the database. However, I only want to render the JSX if I have the correct value for name. How can I go about doing this? I realize this is a simple example, but that was the point, as I spent hours trying to figure out the answer to a more complex version of this. When trying to do this, I would get an error since name was undefined at the time of rendering due to the async call to the database.

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

0

If you don't have the data yet, you can render something else while you're still loading.

For example something like:

if (!name) {
  return null
}

return (
  <View>
    <Text>{name} retrieved data!</Text>
  </View>
)

Some kind of loading indicator would probably be better than the null.

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