How to set a name for individual firebase accounts via expo?

How to set individual names for individual accounts? I have tried to set input boxes for user to type name when registering but after I have register and I did a console log. It says undefined. How do I solve this?

My code for RegisterScreen.js (Part of it)

import { StyleSheet, Text, View, KeyboardAvoidingView, TextInput, TouchableOpacity } from 'react-native'
import React from 'react'
import { useNavigation } from '@react-navigation/native';
import { createUserWithEmailAndPassword } from "firebase/auth"
import { useState } from 'react'
import { auth } from '../firebase'
import { signOut } from 'firebase/auth'

const RegisterScreen = () => {
    const [email, setEmail] = useState('')
    const [password, setPassword] = useState('')
    const [name, setName] = useState('')
    const [showError, setShowError] = useState(false);
    const navigation = useNavigation()
    const handleSignUp = async () => {
        try {
        if (email && password) {
           const { user } = await createUserWithEmailAndPassword(auth, email, password, name)
           console.log('Registered as :' ,;
            await signOut(auth)
            console.log("Signed out successfully")
          }catch (error) {
        } catch (error) {
    return (
    <KeyboardAvoidingView  //To prevent keyboard from blocking the writing area
        behavior = "padding"
        <View style = {styles.inputContainer}> 
                placeholder = "Email"
                onChangeText ={text => setEmail(text)}
                style = {styles.input} 
                placeholder = "Password (Min: 6 chars)"
                onChangeText ={text => setPassword(text)}
                style = {styles.input} 
                secureTextEntry //Hide password
                placeholder = "Name"
                onChangeText ={text => setName(text)}
                style = {styles.input} 
        {showError && <View style={styles.error}>
          <Text>Username or password not valid</Text>
        <View style = {styles.buttonContainer}>
                onPress = {handleSignUp}
                style = {styles.button}
                <Text style={styles.buttonText}>Register</Text>

As stated in the code, I did the following line console.log('Registered as :' ,; and the console returned me as Registered as undefined. How do I correct my code to extract what the user has type for the name and also to save the name for the account in firebase?

If anyone can help with this, thank you very much !