【发布时间】:2020-08-27 21:35:30
【问题描述】:
我是 React Native 的新手,当我使用 this.setState() 更改值时,我无法更新我的变量。单击按钮时,我正在调用此函数:
const updateName = () => {
var user = firebase.auth().currentUser;
user.updateProfile({
displayName: "Test Test"
}).then(function() {
alert('Name changed')
}).catch(function(e) {
alert(e)
})
this.setState({ userFullName: firebase.auth().currentUser.displayName })
}
这会将当前用户的显示名称更新为“Test Test”,我希望此更改能够反映在屏幕上。它当前显示在 userFullName 变量中,但我收到 TypeError: undefined is not an object。有人知道怎么做吗?
【问题讨论】:
-
没有所有代码很难
-
你还需要看什么?
标签: react-native react-native-firebase