反应本地文本的this.setState

问题描述

我是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 })
    }

这会将当前用户的显示名称更新为“测试测试”,我希望此更改能够反映在屏幕上。它当前在userFullName变量中显示,但出现TypeError:undefined不是对象。有人知道该怎么做吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)