Images shows black
See original GitHub issueHi, 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:
- Created 6 years ago
- Comments:5
Well, the first thing: I don’t see where are you calling
getImages()
. It’s supposed to be called incomponentDidMount()
or in another lifecycle method.Also, I’d recommend you to change the function to this:
or even so (cleaner)
This way the function will be guarantied bonded to the component. Please, let me know if you will solve this issue🤞
@ArtiomShapovalov Works amazingly well ! Thank you so much… I’m closing this issue.