0

i am new to react native and will appreciate some guidance. Could one kindly let me know how to retrieve images from my dummy data

i am call images from dummy-data is this way 'require(\'../../assets/images/imgUser01.png\')' but it does not seem to be working. Could kindly advise me the correct way to call the image

screen: enter image description here

i have the below file: dummy-data.js

import User from '../model/user';

export const USER = [
  new User(
    'u1',
    'Aku Peters',
    '28',
    'require(\'../../assets/images/imgUser01.png\')',
    'Lorem ipsum dolor sit amet',
  ),
]

i have the below file Card.js

import React from 'react';
import {Text, ScrollView, TouchableWithoutFeedback} from 'react-native';
import {
  CardContainer,
  CardInnerContainer,
  CardText
} from "../../constants/members-styles";

const Card = (props) => {
  return(
    <CardContainer>
      <ScrollView>
        <TouchableWithoutFeedback>
          <CardInnerContainer>
            <Text>{props.title}</Text>
            <CardText>{props.name}</CardText>
            <Text>ID: {props.id}</Text>
            <Text>Age: {props.age}</Text>
            <Text>Description: {props.description}</Text>
            <Text>Image: {props.image}</Text>
          </CardInnerContainer>
        </TouchableWithoutFeedback>
      </ScrollView>
    </CardContainer>
  )
}

export default Card;
ARTLoe
  • 1,743
  • 2
  • 21
  • 54
  • what is props.image? it must be a string, because youre using a Text component. If you want to render an image use the Image component – Jairo Py Apr 03 '23 at 15:24

0 Answers0