Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!