import React, { useState, useEffect } from "react"; import { Text, View, StyleSheet, Button, ScrollView, TextInput } from "react-native"; import {Picker} from '@react-native-community/picker' import * as SecureStore from 'expo-secure-store'; import axios from "axios"; export default function SettingScreen() { const [currentFaculty, setCurrentFaculty] = useState('') // faculty of backend const [faculty, setFaculty] = useState('') // faculty of dropdown const getFaculty = async ()=>{ const token = await SecureStore.getItemAsync('token') let id = await SecureStore.getItemAsync('id') let user_id = parseInt(id) try { let response = await axios(`http://8c4029a33a9a.ngrok.io/api/get_faculty_name?id=${user_id}`, { method: 'GET', headers: { 'content-type': 'application/json', Authorization: `Token ${token}` }, }) setCurrentFaculty(response.data.FacultyName[0]) } catch(error){ console.log(error) } } useEffect(()=>{ console.log('dimelooo') getFaculty() },[currentFaculty]) const updateFaculty = async()=>{ const token = await SecureStore.getItemAsync('token') let id = await SecureStore.getItemAsync('id') let user_id = id let fac_id = faculty // console.log(typeof(fac_id)) try { let response = await axios({ method: 'PATCH', url: 'http://8c4029a33a9a.ngrok.io/api/update_faculty', headers: { Authorization: `Token ${token}` }, data: { id: user_id, fac_id_id: fac_id } }) console.log(response.data.list) } catch(error){ console.log(error) } setCurrentFaculty(faculty) } console.log(faculty) return( {/* */} You currently belong to the faculty: {currentFaculty} Faculty setFaculty(itemValue) }>