question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Images shows black

See original GitHub issue

Hi, I’m a beginner in react native. Just started using your library in one of my app. A great and an easy to use library. Now, when I render the component for the first time, I make remote calls to my rest API which sends me a bunch of image URIs as a response. I attach the state to these URIs and proceed with setState once the remote response is received. However, the first time when the page loads, it does not show me any images rather shows a black screen (exactly the size of image container). But if I reload the page (HMR) during development , then the Images are drawn correctly and are visible. I reckon setState should eventually update the URIs of the image and re-render the slider view. This is not happening though. Could you please guide me or check this if incase it’s a bug ? Awaiting your response. P.S: I did check the state object after response and console logged it to check if I receive the right URIs and yes indeed I receive proper response and the state object is updated as well. However the image does not show. For now, I use a Timeout to update the view once the setState() is called. I am not sure if this is a right workaround for my situation.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ArtiomShapovalovcommented, Mar 19, 2018

Well, the first thing: I don’t see where are you calling getImages(). It’s supposed to be called in componentDidMount() or in another lifecycle method.

Also, I’d recommend you to change the function to this:

    getImages = () => 
         getpics().then(res => this.setState({pics: res}));

or even so (cleaner)

    getImages = () => 
         getpics().then(pics => this.setState({pics}));

This way the function will be guarantied bonded to the component. Please, let me know if you will solve this issue🤞

0reactions
kkrishnan90commented, Mar 19, 2018

@ArtiomShapovalov Works amazingly well ! Thank you so much… I’m closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Some jpg files display is black - Microsoft Community
All those photos are still black, while the rest of the images in all formats (jpg, png, bmp, tif, etc.) open normally. So,...
Read more >
Why does the image I uploaded appear black? - MyOnlineStore
The image appears black because the original has a transparent background. Usually this happens with .gif or .png images. To prevent this, first...
Read more >
Photos are loading as black boxes, empty boxes ... - Facebook
If you can't see photos on Facebook and you're seeing black boxes, empty boxes or broken images instead: Check if you have images...
Read more >
How to Fix a Transparent Image That Appears With a Black ...
The first time you upload a PNG image with a transparent background, it will display with the transparent background: After the initial upload, ......
Read more >
Images and documents turning black - Apple Community
I have noticed when I am also browsing on safari and google images, some of the images are blank and black also. How...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found