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

How to pass JSON of Images as Data Source? #14

Open
shivamtiwari8736 opened this issue Oct 10, 2019 · 1 comment
Open

How to pass JSON of Images as Data Source? #14

shivamtiwari8736 opened this issue Oct 10, 2019 · 1 comment

Comments

@shivamtiwari8736
Copy link

I have to pass JSON of Image Urls and Image Description. It is only taking Array of Image Urls currently. How to pass a Array of JSON Objects which consist of Image Url, Image Name and Image Description? Thanks

@jchaves07
Copy link
Contributor

you can use a state, in the useeffect load the api const [images, setImages] = useState([]); useEffect(() => { analytics().logEvent(Page_${props.navigation.state.routeName}, {}); api.get(apiEndpoints.news + '0' + '&limit=' + 12).then(response => { //console.log(JSON.stringify(response.data.data.contents)) setImages(response.data.data.contents); }).catch(error => { console.error(error); }); }, []);, set the state with the value, and in the Carousel apply map to the object <Carousel index={5} pageSize={BannerWidth} showsPageIndicator={true}> {images.map((image, index) => renderPage(image, index))} </Carousel>

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

2 participants