Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to display dynamic images #6

Closed
jnoweb opened this issue Jun 8, 2020 · 5 comments
Closed

Unable to display dynamic images #6

jnoweb opened this issue Jun 8, 2020 · 5 comments

Comments

@jnoweb
Copy link

jnoweb commented Jun 8, 2020

I was trying to display dynamic images on the ListTemplate but it is not working. I have gone through the documentation but I can't find anything relating to this. Is it currently possible to perform such action? And if yes, how?

Thanks!

@birkir
Copy link
Owner

birkir commented Aug 20, 2020

What do you mean by dynamic images? Like images as URLs?

@martinthedinov
Copy link
Contributor

@jnoweb Maybe you are hitting a common ReactNative bundler issue, rather than with this library. If you mean dynamic sources being used in images, RN doesn't allow this - see facebook/react-native#2481 . One way around this is to generate different static image paths in a method, and use this method where you want a 'dynamic image', like:

function getDynamicImage(somethingToCompare: string) {
      const image1 = require('../images/image1.jpg');
      const image2 = require('../images/image2.jpg');
  
      switch (somethingToCompare) {
        case "case1":
          return image1;
        case "case2":
          return image2;
      }
    }

@tomdye
Copy link
Collaborator

tomdye commented Mar 15, 2021

@jnoweb I came across some strange quirks when working on this, for example, png files only appear to work if they're post fixed with @3x and all list item images seem to need to be around 80 x 80 px.

@birkir
Copy link
Owner

birkir commented Apr 9, 2021

Good find, let’s add it to the docs!

chownation added a commit to chownation/react-native-carplay that referenced this issue May 20, 2021
@tomdye tomdye closed this as completed Oct 27, 2021
alyssaharvey3 added a commit to alyssaharvey3/react-native-carplay-app that referenced this issue Aug 2, 2023
@harrymash2006
Copy link

@birkir the https images are not loading in ListItem, any clue?:

I am adding this like this:

const podcastItems: ListItem[] = [
{ text: 'Podcast 1', detailText: 'Podcast 1 description', image: { uri: 'https://commondatastorage.googleapis.com/codeskulptor-assets/week5-triangle2.png'}},
{ text: 'Podcast 2', detailText: 'Podcast 2 description', image: require('../images/IHXoEES.png') },

]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants