import { StatusBar } from 'expo-status-bar'; import React, {useState, useEffect} from 'react'; import { View, Image, StyleSheet, Text, Button, ScrollView, Pressable, Alert} from 'react-native'; import data from './transfer.json' import DropDownPicker from 'react-native-dropdown-picker'; //where data will be put var organizedData //where data will be stored var information = "data goes here" //organize data make it pretty function organize(){ } //fix DropDownPicker.setListMode("SCROLLVIEW") //data query variables (global) const queryBase = "https://api.census.gov/data/2020/acs/acs5/profile?get=group" const queryEnd = "&in=state:72" var table = "" var pueblo = "" function updateTable(value){ table = value } function updatePueblo(value){ pueblo = value } //calls data query function loadDoc(query) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { information = this.responseText; //organize() } }; xhttp.open("GET", query, true); xhttp.send(); } //query to copy paste later //"https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP02PR)&for=county:127&in=state:72" //function to create query to fetch data function fetchData() { console.log("fetching data") var query = queryBase + "(" + table + ")&for=county:" + pueblo + queryEnd console.log(query) if(pueblo && table) {loadDoc(query)} else {Alert.alert("Please fill every parameter before calling!")} } //change this to an external css file later const styles = StyleSheet.create({ buttons: { flexDirection: 'row', justifyContent: 'center', marginTop: 40, marginBottom: 30, margin: 30, borderColor: "grey", }, container: { flexDirection: 'column', justifyContent: 'center', backgroundColor: 'black', alignItems: 'center', justifyContent: 'center', marginTop: 20, }, containerbackground:{ backgroundColor: '#063970', marginTop: 20 }, intro: { fontWeight: "bold", color:"#beb2c8", fontSize: 30, }, sub: { color:"#D7D6D6", fontSize: 20 }, scrollView:{ marginHorizontal: 20 }, listItem:{ fontSize: 30, color: "white", textDecorationLines: "underline" }, listButtons:{ fontSize: 15, color: "white", textDecorationLines: "underline" }, buttonsVer: { flexDirection: 'column', justifyContent: 'center', marginTop: 40, marginBottom: 30, margin: 30, borderColor: "grey", } }); //default button press const handlePress = () => false //return INFO function getInfo(){ console.log(information[6]) return information } //button to press to call data //again it only loads the data on the second button press. if anyone knows how to fix this please checked //please //please class DataButton extends React.Component{ state = { click: false } pullData = () => {fetchData(); this.setState({click: true})} render() { return(