1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import React, { useEffect, useState } from 'react';
- import { ActivityIndicator, Button, FlatList, Text, TouchableOpacity, View } from 'react-native';
- import { globalStyles } from '../styles/global';
- import Card from '../shared/card';
-
- export default App = () => {
- const [isLoading, setLoading] = useState(true);
- const [Description, setDescription] = useState([]); // this is looking for 'Description' and it's content
- const [Mocion, setMocion] = useState([]); // this is looking for 'Mocion' and it's content
-
- // this connects us to the API and fetches the json file with the mociones
- const getMociones = async () => {
- try {
- const response = await fetch('http://192.168.1.200:5000/send?PIN=613382'); // connection to the website
- const json = await response.json();
-
- // setting the content of each category
- setMocion(json.Mocion);
- setDescription(json.Description);
- } catch (error) {
- console.error(error);
- } finally {
- setLoading(false); // once found the loading icon will be replaced with the content of the json
- }
- }
-
- useEffect(() => {
- getMociones();
- }, []);
-
-
- // this is for displaying the mocion on the screen
- return (
- <View style={{ flex: 1, padding: 24 }}>
-
- <Text>{Mocion}</Text>
- <Text>{Description}</Text>
- <Button title= 'A favor' color={'#e81b39'} />
- </View>
- );
- };
|