import { Text, View, Image, ScrollView } from 'react-native'; import Header from…
- User
import { Text, View, Image, ScrollView } from 'react-native'; import Header from '../components/Header'; import Footer from '../components/Footer'; import { gStyle } from '../styles/style';
export default function Profile() { return ( {name} Добро пожаловать в{'\n'}личный кабинет Имя Анастасия Фамилия Анастасьева Электронная почта <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS> Номер телефона +7(999)-999-99-99 Оплаченные{'\n'}мастер-классы <Image source={require('../assets/example.jpeg')} style={gStyle.ProfileImg}/> Мастер-класс №1 Время 12:00 12/12/2012 Цена: 350 Р.
); }
how do i write here user's name from firebase db?
- Assistant
You can retrieve the user's name from Firebase database using Firebase Auth and Firebase Realtime Database. Here's an example of how you can update your Profile component to display the user's name:
- Import Firebase dependencies:
codeimport * as firebase from 'firebase'; // Your Firebase configuration const firebaseConfig = { // ... }; // Initialize Firebase firebase.initializeApp(firebaseConfig); - User
what if i want to show not only their name but surname, phone and email?
- Assistant
- User
- Assistant
It appears that the issue is with the import statement for Firebase. Instead of importing the
firebaseobject from theFirebase/firebasefile, try importing it from thefirebasepackage:codeimport firebase from 'firebase/compat/app'; import 'firebase/compat/auth'; import 'firebase/compat/database'; import 'firebase/compat/firestore';Also, make sure that you have initialized Firebase with your project's configuration in a separate file. Here's an example of how you can initialize Firebase in a
firebase.jsfile:codeimport firebase from 'firebase/compat/app'; import 'firebase/compat/auth'; import 'firebase/compat/database'; import 'firebase/compat/firestore'; const firebaseConfig = { // your project's Firebase configuration object }; firebase.initializeApp(firebaseConfig); export default firebase; - User
but can i take from auth firebase data? or there are just email and password?
- Assistant
Firebase Auth provides user account information for currently authenticated users, including the user's
uid,displayName,email,phoneNumber,photoURL, andproviderData. However, note that not all of these properties will be available for all providers. For example, if a user signed up with an email and password, theemailandpasswordproperties will be available, butphoneNumberanddisplayNamemay benull:javascriptconst currentUser = firebase.auth().currentUser; console.log(currentUser.uid); // User's UID console.log(currentUser.displayName); // User's display name (may be null) console.log(currentUser.email); // User's email address (may be null) console.log(currentUser.phoneNumber); // User's phone number (may be null) console.log(currentUser.photoURL); // User's photo URL (may be null) console.log(currentUser.providerData); // Array of user's provider-specific information