Receiving “TypeError: setUser Is Not A Function, (It Is Undefined), But Its Listed As A Const

There’s no other details after that message,but when I attempt to login/register, I’m seeing the “console.log” pop up successfully. Firebase is also receiving the info as well

Here is my Register.js file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { StyleSheet, Text, View, Button, TextInput, Alert } from 'react-native';
import { useState } from 'react';
import { getAuth, createUserWithEmailAndPassword } from 'firebase/auth';
import React from 'react';
import LoginPage from './LoginPage';
import { authentication } from './Config';
import { useAuth } from './AuthContext';
export default function RegisterPage({navigation}) {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const {user, setUser}= useAuth();
const signUp = () => {
createUserWithEmailAndPassword(authentication, email, password)
.then((res) => {
console.log('You Have Successfully Created An Account!');
setUser(res.user);
})
.catch((re) => {
console.log(re);
})
}
return (
<View style={styles.container}>
<Text>Welcome! Create Your Account Here</Text>
<TextInput style = {styles.input}
keyboardType='email-address'
placeholder='Please Enter Your E-Mail Here'
placeholderTextColor={'#aa336a'}
value={email}
onChangeText={(text) => setEmail(text)}
/>
<TextInput
style = {styles.input}
placeholder='Please Enter Your Password Here'
placeholderTextColor={'#aa336a'}
secureTextEntry
value={password}
onChangeText={(text) => setPassword(text)}
/>
<TextInput
style = {styles.input}
placeholder='Please Confirm Your Password Here'
placeholderTextColor={'#aa336a'}
secureTextEntry
value={confirmPassword}
onChangeText={(text) => setConfirmPassword(text)}
/>
<Button title='Create An Account' onPress={signUp}></Button>
<Button title='Not Your First Time Here?' onPress={() => navigation.push('Login')}></Button>
</View>
</code>
<code>import { StyleSheet, Text, View, Button, TextInput, Alert } from 'react-native'; import { useState } from 'react'; import { getAuth, createUserWithEmailAndPassword } from 'firebase/auth'; import React from 'react'; import LoginPage from './LoginPage'; import { authentication } from './Config'; import { useAuth } from './AuthContext'; export default function RegisterPage({navigation}) { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const {user, setUser}= useAuth(); const signUp = () => { createUserWithEmailAndPassword(authentication, email, password) .then((res) => { console.log('You Have Successfully Created An Account!'); setUser(res.user); }) .catch((re) => { console.log(re); }) } return ( <View style={styles.container}> <Text>Welcome! Create Your Account Here</Text> <TextInput style = {styles.input} keyboardType='email-address' placeholder='Please Enter Your E-Mail Here' placeholderTextColor={'#aa336a'} value={email} onChangeText={(text) => setEmail(text)} /> <TextInput style = {styles.input} placeholder='Please Enter Your Password Here' placeholderTextColor={'#aa336a'} secureTextEntry value={password} onChangeText={(text) => setPassword(text)} /> <TextInput style = {styles.input} placeholder='Please Confirm Your Password Here' placeholderTextColor={'#aa336a'} secureTextEntry value={confirmPassword} onChangeText={(text) => setConfirmPassword(text)} /> <Button title='Create An Account' onPress={signUp}></Button> <Button title='Not Your First Time Here?' onPress={() => navigation.push('Login')}></Button> </View> </code>
import { StyleSheet, Text, View, Button, TextInput, Alert } from 'react-native';
import { useState } from 'react';
import { getAuth, createUserWithEmailAndPassword } from 'firebase/auth';
import React from 'react';


import LoginPage from './LoginPage';
import { authentication } from './Config';
import { useAuth } from './AuthContext';

export default function RegisterPage({navigation}) {

  const [email, setEmail]  = useState("");
  const [password, setPassword] = useState("");
  const [confirmPassword, setConfirmPassword] = useState("");
  const {user, setUser}= useAuth();

  const signUp = () => {
    createUserWithEmailAndPassword(authentication, email, password)
      .then((res) => {
        console.log('You Have Successfully Created An Account!');
        setUser(res.user);
      })
      .catch((re) => {
        console.log(re);
      })

   }


  return (
    <View style={styles.container}>
      <Text>Welcome! Create Your Account Here</Text>
      <TextInput style = {styles.input}
       keyboardType='email-address'
       placeholder='Please Enter Your E-Mail Here'
       placeholderTextColor={'#aa336a'}
       value={email}
       onChangeText={(text) => setEmail(text)}
    />
     <TextInput
     style = {styles.input}
     placeholder='Please Enter Your Password Here'
     placeholderTextColor={'#aa336a'}
     secureTextEntry
     value={password}
     onChangeText={(text) => setPassword(text)}
  />   
  <TextInput
     style = {styles.input}
     placeholder='Please Confirm Your Password Here'
     placeholderTextColor={'#aa336a'}
     secureTextEntry
     value={confirmPassword}
     onChangeText={(text) => setConfirmPassword(text)}
  /> 
  <Button title='Create An Account'  onPress={signUp}></Button>
  <Button title='Not Your First Time Here?' onPress={() => navigation.push('Login')}></Button>
</View>

);
}

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ffb3c6',
alignItems: 'center',
justifyContent: 'center',
},
input: {
width: 340,
height: 57,
backgroundColor: '#d6b4fc',
alignItems:'center',
justifyContent: 'center',
marginTop: 17
},
</code>
<code>const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#ffb3c6', alignItems: 'center', justifyContent: 'center', }, input: { width: 340, height: 57, backgroundColor: '#d6b4fc', alignItems:'center', justifyContent: 'center', marginTop: 17 }, </code>
const styles = StyleSheet.create({
  container: {
   flex: 1,
   backgroundColor: '#ffb3c6',
   alignItems: 'center',
   justifyContent: 'center',
 },
 input: {
 width: 340, 
 height: 57,
 backgroundColor: '#d6b4fc',
 alignItems:'center',
 justifyContent: 'center',
 marginTop: 17
},

});

As well As my Login.js

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { StyleSheet, Text, View, Button, Alert, TextInput } from 'react-native';
import { useRef, useState } from 'react'
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
import React from 'react';
import RegisterPage from './RegisterPage';
import { authentication } from './Config';
import { useAuth } from './AuthContext';
export default function LoginPage({navigation}) {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const {user, setUser } = useAuth();
const inputRef = useRef();
const passwordRef = useRef();
const signIn = async () => {
signInWithEmailAndPassword(authentication, email, password)
.then ((res) =>{
console.log('You Have Successfully Signed In!');
setUser(res.user);
})
.catch ((err) => {
console.log(err);
setError('Error In Signing In')
})
};
return (
<View style={styles.container}>
<Text>Welcome Back! Please Sign In</Text>
<TextInput
ref={inputRef}
style={styles.input}
placeholder='Please Enter Your E-Mail Here'
keyboardType='email-address'
placeholderTextColor={'#aa336a'}
value={email}
onChangeText={(email) => setEmail(email)}
/>
<TextInput
ref={passwordRef}
style= {styles.input}
placeholder='Please Enter Your Password Here'
placeholderTextColor={'#aa336a'}
value={password}
secureTextEntry
onChangeText={(text) => setPassword(text)}
/>
<Button title='Login' onPress={signIn}></Button>
<Button title='First Time Here?'onPress={() => navigation.push('Register')}></Button>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
input: {
width: 340,
height: 57,
backgroundColor: '#d6b4fc',
justifyContent: 'center',
alignItems: 'center',
marginTop: 17
},
});
</code>
<code>import { StyleSheet, Text, View, Button, Alert, TextInput } from 'react-native'; import { useRef, useState } from 'react' import { getAuth, signInWithEmailAndPassword } from 'firebase/auth'; import React from 'react'; import RegisterPage from './RegisterPage'; import { authentication } from './Config'; import { useAuth } from './AuthContext'; export default function LoginPage({navigation}) { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const {user, setUser } = useAuth(); const inputRef = useRef(); const passwordRef = useRef(); const signIn = async () => { signInWithEmailAndPassword(authentication, email, password) .then ((res) =>{ console.log('You Have Successfully Signed In!'); setUser(res.user); }) .catch ((err) => { console.log(err); setError('Error In Signing In') }) }; return ( <View style={styles.container}> <Text>Welcome Back! Please Sign In</Text> <TextInput ref={inputRef} style={styles.input} placeholder='Please Enter Your E-Mail Here' keyboardType='email-address' placeholderTextColor={'#aa336a'} value={email} onChangeText={(email) => setEmail(email)} /> <TextInput ref={passwordRef} style= {styles.input} placeholder='Please Enter Your Password Here' placeholderTextColor={'#aa336a'} value={password} secureTextEntry onChangeText={(text) => setPassword(text)} /> <Button title='Login' onPress={signIn}></Button> <Button title='First Time Here?'onPress={() => navigation.push('Register')}></Button> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, input: { width: 340, height: 57, backgroundColor: '#d6b4fc', justifyContent: 'center', alignItems: 'center', marginTop: 17 }, }); </code>
import { StyleSheet, Text, View, Button, Alert, TextInput } from 'react-native';
import { useRef, useState } from 'react'
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
import React from 'react';
import RegisterPage from './RegisterPage';
import { authentication } from './Config';
import { useAuth } from './AuthContext';

export default function LoginPage({navigation}) {

  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
  const {user,  setUser } = useAuth();

  const inputRef = useRef();
  const passwordRef = useRef();




  const signIn = async () => {

    signInWithEmailAndPassword(authentication, email, password)
      .then ((res) =>{
        console.log('You Have Successfully Signed In!');
        setUser(res.user);
      })

      .catch ((err) => {
        console.log(err);
        setError('Error In Signing In')
      })

  };

  return (
    <View style={styles.container}>
      <Text>Welcome Back! Please Sign In</Text>
     <TextInput
         ref={inputRef}
         style={styles.input}
         placeholder='Please Enter Your E-Mail Here'
         keyboardType='email-address'
         placeholderTextColor={'#aa336a'}
         value={email}
         onChangeText={(email) => setEmail(email)}
      />
       <TextInput
         ref={passwordRef}
         style= {styles.input}   
         placeholder='Please Enter Your Password Here'
         placeholderTextColor={'#aa336a'}
         value={password}
         secureTextEntry
         onChangeText={(text) => setPassword(text)}
      />
      <Button title='Login' onPress={signIn}></Button>
      <Button title='First Time Here?'onPress={() => navigation.push('Register')}></Button>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  input: {
    width: 340,
    height: 57,
    backgroundColor: '#d6b4fc',
    justifyContent: 'center',
    alignItems: 'center',
    marginTop: 17
  },
});

I tried turning the curly brackets into an array, but that caused an error that wouldn’t cause the page to load

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật