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

231
Visualizações
React Native don't show image when I fetch image file path from database

I have a database with a courses table.

enter image description here

I want to show the image through the image path saved in the field image column.

In my react native app I have a component that lists Carts where cart's images are saved in disk

Like: C:\Users\Public\Pictures\Rectangle_2.png. Then I put the path in image column.

CartList.js

import Carts from './../Cart';
const Item = ({item}) => {
  return (
    <Carts
      name={item.name}
      price={item.price}
      offPrice={item.offPrice}
      image={item.image}
    />
  );
};
class CartList extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data: [],
    };
  }
  componentDidMount() {
    this.requestAPI();
  }
  requestAPI = () => {
    const apiURL = 'http://myApi/api/courses';
    fetch(apiURL)
      .then(response => response.json())
      .then(responseJson => {
        this.setState({
          data: responseJson,
        });
      });
  };

  renderItem = ({item}) => {
    return <Item item={item} />;
  };
  render() {
    return (
      <>
        <FlatList
          data={this.state.data}
          renderItem={this.renderItem}
          keyEtractor={item => item.id.toString()}
        />
      </>
    );
  }
}

I access to image path through props in Cart.

Cart.js

const Cart = (props) => {
  return (
    <View
      <Image
        style={{
          width: '40%',
          height: 100,
        }}
        source={{uri:props.image}}
      />
    </View>
  );
};
export default Cart;

when I run the app, then I get this error:

enter image description here

How can I solve this problem?

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

0

This happens if you have incorrect image path, please check that your remote path of image is correct, I think the image path is misleading.

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