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

102
Vistas
how to use image source in another file different from the file contains the image?

i am trying to use an image source with require function or uri in react native but the source will be use in calling the function that has the image, it doesn't work with me.

this is the image the contains the structure of the project and the image folder. enter image description here

this is the card file code:

import { View, Image, StyleSheet } from "react-native";
import colors from "../config/colors";
import React from "react";
import BookStoreText from "./BookStoreText";

function Card(title,subtitile,image) {
    return (
      <View style={styles.card}>
        <Image source={image} />
        <BookStoreText>{title}</BookStoreText>
        <BookStoreText>{subtitile}</BookStoreText>
      </View>
    );
}
const styles = StyleSheet.create({
    card:{
        borderRadius:15,
        backgroundColor:colors.white,
        marginBottom:20,
    }
})

export default Card;

this is the app.js source code:

//import WelcomeScreen from "./app/screens/WelcomeScreen";
//import colors from "./app/config/colors";
//import ViewImageScreen from "./app/screens/ViewImageScreen";
//import { MaterialCommunityIcons } from "@expo/vector-icons";
//import AppButton from "./app/components/AppButton";
import { View } from "react-native";
import React from "react";
import Card from "./app/components/Card";
function App() {
  return (
    <View
      style={{
        padding: 20,
        paddingTop: 100,
        backgroundColor: "#f8f4f4",
      }}
    >
      <Card
        image={require("./app/assets/chair.jpg")}
      ></Card>
    </View>
  );
}
export default App;

what i tried: i tried to use uri with the image istead of using require function but it doesn't work

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you need to destructure the image property in the Appcard component's params like this:

//notice the curly braces here
    function Card({title,subtitile,image}) {
        return (
          <View style={styles.card}>
            <Image source={image} />
            <BookStoreText>{title}</BookStoreText>
            <BookStoreText>{subtitile}</BookStoreText>
          </View>
        );
    }
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