【发布时间】:2021-05-31 08:25:49
【问题描述】:
我正在尝试使用 updateProfile() 更新用户的个人资料
当我完全按照link above 中的示例调用该函数时,它会抛出TypeError: currentUser.updateProfile is not a function。我尝试console.log() 用户,但奇怪的是它没有显示updateProfile() 功能。
我正在使用从auth.onAuthStateChanged() 检索到的用户。然后我使用 Firebase firestore 来存储其他用户信息。我将该用户对象与从 firestore 检索到的数据合并:
const mergedUser = Object.assign({}, user, doc.data())
我将mergedUser 传递给一个useState() currentUser,该currentUser 将传递给我的上下文提供程序值。
其他一切都有效,但应该在 userobject 上的函数在 Object.assign() 之后不存在。如何合并用户对象,以便我可以访问所有用户数据和 firebase 用户功能,例如updateProfile()
提前谢谢你!
package.json:
{
"name": "planom",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"firebase": "^8.2.7",
"next": "10.0.6",
"react": "17.0.1",
"react-dom": "17.0.1",
"sass": "^1.32.7"
},
"devDependencies": {}
}
【问题讨论】:
标签: reactjs firebase google-cloud-firestore firebase-authentication next.js