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

265
Vistas
React native, ImageBackground check image has loaded before navigating to page

Is there a way I can check if the image has loaded before navigating to a page?

My image if loaded from a url then displayed to the background, I get random errors saying ImageBackground is undefined.

Redux shows the image existing in the store, but I still get the error when navigating to the page:

export const RescueMeLandingScreen = (props) => {
  const { navigation } = props;

  const {
    rescueMe: {
      rescueMeSplashScreen: {
        backgroundImage: { url }, //https://xxx/v3/assets/bltba214d69f78d0dfb/blt90b1f745b5b348ef/62333622893506175b30a63f/xxx.png
        buttonText,
        informationText,
        title: pageTitle,
      },
    },
  } = useSelector((state) => state);

...

  return (
    <>
      <RACPageStructure loading={false} title={pageTitle} isMain>
        <ScrollView contentContainerStyle={styles.scollView}>
          <ImageBackground source={{ uri: url }} style={styles.imageBackground}>
       ...
          </ImageBackground>
        </ScrollView>
      </RACPageStructure>
    </>
  );
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could try conditionally rendering the component.

Example:

{ url !== undefined &&  <ImageBackground>}

If that doesn't work, you could also create a custom component wrapper for your component that would return a default image if the other one is undefined.

Example:

const ImageBackgroundWrapper = () => {
  if (url === undefined) {
    return ();
  } else {
    return ();
  }
}
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