Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load Android image in React Native

I'm trying to load image from Android's drawble resources library using React Native.

I tried to require it like this:

<Image source={require("image!some-image")} />

And:

<Image source={{uri: "some-image", isStatic: true}} />

But no luck.. I know that I can require image from the js path but in this case I need it from the 'res' folder.

like image 344
Guy Segal Avatar asked Aug 04 '16 09:08

Guy Segal


1 Answers

There are three things that could possibly be wrong.

  1. Android does not support '-' in image names. use '_' instead.
  2. Ensure that you are rebuilding the app when you add the asset (react-native run-android). This should be done every time you add/modify an asset to the res folder

3.There ought to be a ',' before isStatic.

<Image source={{uri: "some-image" isStatic: true}} />. I'm guessing this was a typo

like image 136
Nishanth Shankar Avatar answered Nov 10 '22 07:11

Nishanth Shankar