/*import React from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, Image, TouchableOpacity, } from 'react-native'; import { Header, LearnMoreLinks, Colors, DebugInstructions, ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; import {WebView} from 'react-native-webview'; import LinearGradient from 'react-native-linear-gradient'; import { Linking } from 'react-native'; import { url } from './resources/fetchInfo.json' //import I18n from './i18n'; class Poll extends React.Component { /*constructor(props) { super(props) this.state = { data: [] } } componentDidMount() { fetch(`${url}/api/en/lunchEvents`,{ headers: { 'Cache-Control': 'no-cache' } } ) .then((response) => { return response.text(); }) .then((json) => { this.setState({data: JSON.parse(json)}); }) .catch((error) => console.error(error)) }*/ /* render() { return ( Linking.openURL("https://google.com")}> Take A Poll! ) } } export default Poll;*/ import React from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, } from 'react-native'; import { Header, LearnMoreLinks, Colors, DebugInstructions, ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; import { url } from './resources/fetchInfo.json' import {WebView} from 'react-native-webview'; import I18n from 'i18n-js'; class Poll extends React.Component { constructor(props) { super(props) this.state = { data:[] } } componentDidMount() { fetch(`${url}/api/`+String(I18n.locale).split('-')[0]+`/polls`,{ headers: { 'Cache-Control': 'no-cache' }} ).then((response) => { return response.text(); }).then((json) => { const data = JSON.parse(json) data.sort((a,b)=>a.id-b.id) this.setState({data: data}); }).catch((error) => console.error(error)) } render() { if (this.state.isLoading) { return } else { if (this.state.data.length==0) { return ( No Poll ) } else { return ( ) } } } } export default Poll;