Aucune description

HomeScreen.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { propertiesListToString } from "@expo/config-plugins/build/android/Properties";
  2. import React, { useEffect, useState }from "react";
  3. import { StyleSheet, View, Text, Button } from 'react-native';
  4. import { globalStyles } from "../styles/global";
  5. export default App = ({ navigation }) => {
  6. const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
  7. // this connects us to the API and fetches the json file with the mociones
  8. const getMociones = async () => {
  9. try {
  10. const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website
  11. const json = await response.json();
  12. // setting the content of each category
  13. setPIN(json.PIN);
  14. } catch (error) {
  15. console.error(error);
  16. } finally {
  17. setLoading(false); // once found the loading icon will be replaced with the content of the json
  18. }
  19. }
  20. const pressHandler = () => {
  21. navigation.navigate('Mocion');
  22. }
  23. useEffect(() => {
  24. getMociones();
  25. }, []);
  26. return (
  27. <View style = {globalStyles.container}>
  28. <Text style = {globalStyles.tittleText}>Home Screen</Text>
  29. <Button title="go to pin page" onPress={pressHandler}/>
  30. </View>
  31. )
  32. }