Firebase + react - db._checkNotDeleted is not a function как исправить
Не могу понять в чем проблема, не могу закинуть даже тестовые данные.
firebase.js
import { initializeApp } from 'firebase/app'
import {getAuth} from 'firebase/auth'
const firebaseConfig = {
apiKey: "---",
authDomain: "---",
databaseURL: "---",
projectId: "---",
storageBucket: "---",
messagingSenderId: "---",
appId: "---"
}
// Initialize Firebase and Firebase Authentication
const app = initializeApp(firebaseConfig)
const auth = getAuth(app)
export {auth}
ProfileEdit.js
import { useAuthValue } from './AuthContext'
import { signOut } from 'firebase/auth'
import { getDatabase, ref, child, push, update,set } from "firebase/database";
import React, { useState, useEffect } from 'react';
import xtype from 'xtypejs'
import { auth } from './firebase'
function ProfileEdit() {
const { currentUser } = useAuthValue();
const db = ref(getDatabase());
const [name, setName] = useState()
const [phone, setPhone] = useState()
const [payment, setPayment] = useState()
const [address, setAddress] = useState()
const Submit = () => {
const postData = {
address: "test",
firstName: "test",
paymentByCard: "test",
phone: "test",
};
const data = {}
data["users/" + currentUser?.uid] = postData
console.log(data)
return update(ref(db,data))
}
console.log(currentUser?.uid)
return (
<form action="" className="profile-filling" >
<input type="text" name={"name"} id="" placeholder="Enter your firstname" />
<input type="text" name={"address"} id="" placeholder="Enter your Address" />
<input type="text" name={"phone"} id="" placeholder="Enter your phoneNumber" />
<div>
<span> Credit cart? </span>
<input type="checkBox" name={"payment"} id="" placeholder="Enter your firstname" />
<span>Cahs?</span>
<input type="checkBox" name={"payment"} id="" placeholder="Enter your firstname" />
</div>
<span onClick={Submit}>Submit</span>
</form>
)
}
export default ProfileEdit
Ответы (1 шт):
Автор решения: Anton Buketov
→ Ссылка
Переделал по другому. Так же я обращался немного с ошибкой Users должно было начинаться с капса.
const Submit = () => {
const postData = {
address: address,
firstName: name,
paymentByCard: payment,
phone: phone,
};
const data = {}
data["Users/" + currentUser?.uid] = postData
console.log(data)
update(ref(db), data)