Skip to content

Instantly share code, notes, and snippets.

@obliviusm
Created October 19, 2018 13:40
Show Gist options
  • Select an option

  • Save obliviusm/d78ad6c05ffde56340a3ed37a4bbe2bb to your computer and use it in GitHub Desktop.

Select an option

Save obliviusm/d78ad6c05ffde56340a3ed37a4bbe2bb to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import { View } from 'react-native'
import VideoCarousel from './VideoCarousel'
import styles from './styles'
import { LinearGradient } from 'expo'
import api from '../../services/FixtureApi'
import Spinner from '../Spinner'
class Home extends Component {
constructor() {
super()
this.state = {
videos: [],
isLoading: false,
}
}
componentDidMount() {
this.getVideos()
}
async getVideos() {
try {
const response = await api.getVideos()
this.setState({
videos: response.data,
isLoading: true,
})
} catch (error) {
alert('Server Error')
}
}
render() {
if (!this.state.isLoading) {
return <Spinner />
}
return (
<LinearGradient colors={['#F2F2F2', '#3061D9']} style={styles.container}>
<View style={styles.holder}>
<VideoCarousel videoSlides={this.state.videos} />
</View>
</LinearGradient>
)
}
}
export default Home
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment