Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React/Firebase用户注册承诺-Can';t在未安装的组件上调用setState_Javascript_Reactjs_Firebase_Firebase Authentication - Fatal编程技术网

Javascript React/Firebase用户注册承诺-Can';t在未安装的组件上调用setState

Javascript React/Firebase用户注册承诺-Can';t在未安装的组件上调用setState,javascript,reactjs,firebase,firebase-authentication,Javascript,Reactjs,Firebase,Firebase Authentication,我正在尝试这样做: firebase.auth() .createUserWithEmailAndPassword(this.state.email, this.state.password) .then( data => { const {user} = data; if (user) { user.updateProfile({displayName: name}) .then(() =&g

我正在尝试这样做:

firebase.auth()
    .createUserWithEmailAndPassword(this.state.email, this.state.password)
    .then( data => {
        const {user} = data;
        if (user) {
            user.updateProfile({displayName: name})
            .then(() => {
                // when i try to change state for reload, it says its unmounted??
                this.forceUpdate()
            })
        }
    })
    .catch((error) => {
        this.setState({errors: error.message})
    })
其中,在创建用户后,它还会更新其displayName。我想强制刷新/状态更改,因为有一个组件正在等待displayName。但是,它给了我一个错误
无法在未安装的组件上调用setState…

有人能解释错误的原因吗?最好的处理方法是什么


编辑。当用户提交注册表单时会调用此代码

您在哪里调用此代码?在卸载组件时您没有取消请求,请查看您是否尝试使用状态重新呈现而不是强制呈现?@Anthony我在用户提交注册时调用此代码form@joseluismurillorios是的,我也试过设置状态,但是我得到了同样的错误,你在哪里调用这个代码?当组件卸载时,你没有取消你的请求,看看你是否尝试过使用状态重新渲染而不是强制渲染?@Anthony我在用户提交注册时调用这个form@joseluismurillorios是的,我也试过设置状态,但是我得到了同样的错误