Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
React Native Uri is not Displaying

I have a TouchableOpacity set up as shown below:

<View style={{flexDirection: 'row'}}>
   <TouchableOpacity onPress={() => selectImage()} style={{backgroundColor: COLORS.lightGray3, width: SIZES.width, height: 200, borderTopRightRadius: 15, borderTopLeftRadius: 15,}}>

       <TouchableOpacity onPress={() => setModal(!modal)} style={{backgroundColor: 'white', width: 20, height: 20, borderRadius: 15, alignSelf:'flex-end', right: 10, top: 10}}>
           <Icon name='x' size={20} style={{color: 'red'}}/>
       </TouchableOpacity>

       {array.picture == null ? 
       <View style={{alignItems: 'center', flexDirection: 'column', top: 50}}>
          <Text>No Image Selected. </Text>
       </View>
       :
       <Image resizeMode='cover' source={{uri: array.picture}} /> 
       }

   </TouchableOpacity>
</View>

In this TouchableOpacity is a conditional to load an image uri from an array once the image has been selected via selectImage(); even if array.picture IS NOT equal to null, it will either display the same "No Image Selected" text, or a gray background.

ARRAY:

[{"name": "test", "picture": "file:///Users/user/Library/Developer/CoreSimulator/Devices/C10A4A25-D633-44E8-AE53-AD8DD9601A82/data/Containers/Data/Application/C68582F5-CA35-4DD6-9D15-36A254411CD9/tmp/3E9EBBE3-AC1A-4C61-927E-DD168BD037A5.jpg", "price": 12}]

PICTURE OF DISPLAY:enter image description here

ALSO, this is all displayed within a modal.

Anyone sure as to why this is occurring? Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If it's an array then try your condition like this you can either map it or just take picture from first index

  {array.length>0 ? 
      <Image resizeMode='cover' source={{uri: array[0]?.picture}} /> 
     :
      <View style={{alignItems: 'center', flexDirection: 'column', top: 50}}>
        <Text>No Image Selected. </Text>
      </View>
            
  }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda