Files
EMI-ExpoAPP/components/UserName.js
T

25 lines
786 B
JavaScript

import React, { useState, useEffect } from 'react';
import { Text, View, ScrollView, Button, StyleSheet } from 'react-native';
import API from './../API.js';
import { useNavigation } from '@react-navigation/native';
let UserName = (props) => {
let [profile, setProfile] = useState({});
const navigation = useNavigation();
useEffect(async () => {
let p = await API.getUserProfile(props.profileid).catch(()=>{return {}});
setProfile(p);
}, [props.profileid]);
return (
<Text onPress={()=>{navigation.navigate('Profile', {profileid: props.profileid})}} >{profile.profile && profile.profile.firstName} {profile.profile && profile.profile.lastName}</Text>
);
}
export default React.memo(UserName);
const styles = StyleSheet.create({
});