Firebase TypeError:无法读取属性';本地';未定义的

Firebase TypeError:无法读取属性';本地';未定义的,firebase,react-native,google-cloud-firestore,firebase-authentication,Firebase,React Native,Google Cloud Firestore,Firebase Authentication,我正在React Native应用程序中实施firebase电话号码验证。我遵循以下文件: 这将成功运行: const {confirm} = await firebase.auth().signInWithPhoneNumber(value); this.setState({confirm}) console.log(confirm) // is a function 现在,当我运行确认(代码)时: 它给出了以下错误: TypeError:无法读取未定义的属性“native” 我找

我正在React Native应用程序中实施firebase电话号码验证。我遵循以下文件:

这将成功运行:

const {confirm} = await firebase.auth().signInWithPhoneNumber(value);
this.setState({confirm})
console.log(confirm)     // is a function
现在,当我运行确认(代码)时:

它给出了以下错误: TypeError:无法读取未定义的属性“native”

我找了很多,但没能解决它。请帮忙。

您现在已经从变量分配了一个函数,但正在从状态值运行它。在变量上运行

试试看{
等待确认('123456');//用户输入的代码
//成功登录-已触发onAuthStateChanged
}捕获(e){
console.error(e);//无效代码
}

请做点喜欢的事

this.state = {confirmResult: null};
然后

然后

const { confirmResult } = this.state;

try {
   await confirmResult.confirm('123456');
   // Successful login - onAuthStateChanged is triggered
} catch (e) {
   console.error(e); // Invalid code
}

我实际上是在生成confirm时将其存储在状态中。这就是为什么我要在州里运行它。非常感谢你,它成功了。你节省了我的时间。你能告诉我,你是怎么想出来的吗。或者是什么问题?
const confirmResult = await firebase.auth().signInWithPhoneNumber(value);
this.setState({confirmResult});
const { confirmResult } = this.state;

try {
   await confirmResult.confirm('123456');
   // Successful login - onAuthStateChanged is triggered
} catch (e) {
   console.error(e); // Invalid code
}