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

311
Vistas
React - Image with undefined uri is not being updated on iOS

I am trying to update an image based on an stateful URL (changing the URL to 'undefined'). For some reasons, I have to recreate the image on iOS devices or they will not be updated... Check this snack.

Here is the code:

export default function App() {
  const [uri, setUri] = React.useState(
    "https://ichef.bbci.co.uk/news/640/cpsprodpb/150EA/production/_107005268_gettyimages-611696954.jpg"
  );

  console.log({ uri });

  //
  // Doesn't work on iOS if I do not pass a dynamic 'key' prop,
  // which will cause the recreation of the component...
  //
  const renderImage = () =>
    <Image /* key={uri} */ resizeMode="cover" source={{ uri }} style={styles.image} />

  return (
    <View style={styles.container}>
      {renderImage()}

      <TouchableOpacity onPress={() => setUri(undefined)}>
        <Text style={styles.paragraph}>
          Remove Image!
        </Text>
      </TouchableOpacity>
    </View>
  );
}

Any ideas why this happen?

about 4 years ago · Juan Pablo Isaza
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