12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { propertiesListToString } from "@expo/config-plugins/build/android/Properties";
- import React, { useEffect, useState }from "react";
- import { StyleSheet, View, Text, Button } from 'react-native';
- import { globalStyles } from "../styles/global";
-
- export default App = ({ navigation }) => {
- const [PIN, setPIN] = useState([]); // this is looking for 'PIN' 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=121071'); // connection to the website
- const json = await response.json();
-
- // setting the content of each category
- setPIN(json.PIN);
-
- } catch (error) {
- console.error(error);
- } finally {
- setLoading(false); // once found the loading icon will be replaced with the content of the json
- }
- }
-
- const pressHandler = () => {
- navigation.navigate('Pinpage', {Pin:PIN},) // with this we send parameters to other screens
- }
-
- useEffect(() => {
- getMociones();
- }, []);
-
- return (
- <View style = {globalStyles.container}>
- <Text style = {globalStyles.tittleText}>Home Screen</Text>
- <Button title='Ir a pagina de pin' onPress={pressHandler} />
- </View>
-
-
-
-
- )
- }
|