Amirth
Amirth

Reputation: 155

How to pass prop for an image stored locally in react-native

I tried to pass a prop for the 'require' in IMAGE tag of the react-native component. But, it shows an error "Server code Error 500". The same if I pass a link using URI it works with the props.

Working :

<Image
        style={{ width: 70, height: 61 }}
        source={{ uri: imgCode }}
      />


imgCode="https://i.imgur.com/edgLzLO.png"

Need a fix:

<Image
          style={{ width: 70, height: 61 }}
          source={require('./images/header_arrow.png')}
        />

imgCode="./images/batter_logo.png"

Upvotes: 1

Views: 588

Answers (1)

Bhojani Asgar
Bhojani Asgar

Reputation: 103

<Image
    style={{ width: 70, height: 61 }}
    source={require({ uri: imgCode })}
  />


imgCode="https://i.imgur.com/edgLzLO.png"

Try this This may work

Upvotes: 1

Related Questions