Created
October 19, 2018 13:40
-
-
Save obliviusm/d78ad6c05ffde56340a3ed37a4bbe2bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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