diff --git a/app/Announcements.js b/app/Announcements.js index a0e8223..6d63080 100644 --- a/app/Announcements.js +++ b/app/Announcements.js @@ -6,6 +6,7 @@ import { View, Text, StatusBar, + FlatList, } from 'react-native'; import { @@ -16,11 +17,49 @@ import { ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; +import styles from './styles/liststyles' + +const Announcement = ({item}) => { + return ( + + {item.item.message} + + ) +} + class Announcements extends React.Component { + + constructor(props) { + super(props) + this.state = { + data: [] + } + } + + componentDidMount() { + fetch('https://6dc2642ae9b3.ngrok.io/api/en/announcements',{ + headers: { + 'Cache-Control': 'no-cache' + } + } + ) + .then((response) => { + return response.text(); + }) + .then((json) => { + this.setState({data: JSON.parse(json).data}); + }) + .catch((error) => console.error(error)) + } + render() { return ( - - + + } + keyExtractor={item=>JSON.stringify(item)} + /> ) } diff --git a/app/LunchEvents.js b/app/LunchEvents.js index 2d7234e..2134fc8 100644 --- a/app/LunchEvents.js +++ b/app/LunchEvents.js @@ -56,9 +56,6 @@ class LunchEvents extends React.Component { this.setState({data: JSON.parse(json)}); }) .catch((error) => console.error(error)) - .finally(() => { - this.setState({ isLoading: false }); - }); } render() {