reactjs - Firebase 的电话验证确认(代码)不是函数错误
问题描述
import React,{useEffect, useState} from 'react';
import {
View,
} from 'react-native';
import Circle from '../components/Circle';
import MainContainer from '../components/MainContainer';
import AuthContents from '../components/AuthContents';
const Code = ({navigation, route}) => {
const [confirm, setConfirm] = useState(null)
useEffect( () => {
console.log('Code')
OTP()
}, [])
async function OTP()
{
try{
const confirmation = await route.params.confirmation
setConfirm(confirmation)
}catch(e)
{
alert(JSON.stringify(e))
}
}
const CodeAuthenticate = async (value) => {
console.log(confirm)
if (value.length === 6) {
//
//Send code
//
const result = await confirm.confirm(value);
console.log(result)
if (result.additionalUserInfo.isNewUser) {
navigation.navigate('UserData', { uid: result.user.uid })
} else {
navigation.navigate('ChatList')
}
}
}
return (
<MainContainer>
<View style={{ flex: 1 }}>
<Circle />
<AuthContents length = {6} placeholderValue='Enter Code' onPress={CodeAuthenticate} />
</View>
</MainContainer>
)
}
export default Code;
错误
可能的未处理承诺拒绝(id:0):TypeError:confirm.confirm 不是函数。(在 'confirm.confirm(value)' 中,'confirm.confirm' 未定义)
CodeAuthenticate$@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:119464:64 tryCatch@http://localhost:8081/index.bundle?platform= android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7708:23 invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7881:32 tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7708:23 invoke@http://localhost:8081/index.bundle?platform=android&dev =true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7781:30 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7811:19 tryCallTwo@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:28586:9 doResolve@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:28750:25 Promise@http://localhost:8081/index.bundle?platform=android&dev =true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:28609:14 callInvokeWithMethodAndArg@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7810:33 enqueue @http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7815:157 async@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:7832:69 CodeAuthenticate@http://localhost: 8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:119452:40 onPress@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly =false&runModule=true:116179:31 _performTransitionSideEffects@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:61638:22 _receiveSignal@http://localhost:8081 /index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:61580:45 onResponderRelease@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:61487:34 invokeGuardedCallbackProd@http://localhost:8081/ index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:9638:21 invokeGuardedCallback@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule =true:9742:42 invokeGuardedCallbackAndCatchFirstError@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:9746:36 executeDispatch@http://localhost:8081/index .bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:9818:48 executeDispatchesInOrder@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:9838:26 executeDispatchesAndRelease@http://localhost: 8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:11091:35 forEach@[native code] forEachAccumulated@http://localhost:8081/index.bundle?platform=android&dev=true&minify =false&app=com.chatu&modulesOnly=false&runModule=true:10361:22 runEventsInBatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:11115:27 runExtractedPluginEventsInBatch@http ://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:11195:25 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:11170:42 batchedUpdates$1@http ://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:22280:20 batchedUpdates@http://localhost:8081/index.bundle?platform=android&dev=true&minify= false&app=com.chatu&modulesOnly=false&runModule=true:11077:36 _receiveRootNodeIDEvent@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:11169:23 receiveTouches@http: //localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:11223:34 __callFunction@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:3262:36 http://localhost:8081/ index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:2986:31 __guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule =true:3213:15 callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:2985:21 callFunctionReturnFlushedQueue@[本机代码]dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:3262:36 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:2986:31 __guard@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:3213:15 callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify =false&app=com.chatu&modulesOnly=false&runModule=true:2985:21 callFunctionReturnFlushedQueue@[本机代码]dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:3262:36 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:2986:31 __guard@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:3213:15 callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify =false&app=com.chatu&modulesOnly=false&runModule=true:2985:21 callFunctionReturnFlushedQueue@[本机代码]31 __guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:3213:15 callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform= android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:2985:21 callFunctionReturnFlushedQueue@[本机代码]31 __guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:3213:15 callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform= android&dev=true&minify=false&app=com.chatu&modulesOnly=false&runModule=true:2985:21 callFunctionReturnFlushedQueue@[本机代码]
解决方案
推荐阅读
- sql - 比较 pl/sql 中的日期
- java - 使用 ConfigProperties 注入对象的 Junit 测试为空
- r - r 中有没有办法使用对象名称的字符列表来改变这些对象与 base::lapply 和 dplyr::mutate
- indexing - 使用数组进行数组索引
- scheme - 如果没有对 Scheme 的下限和舍入函数的先验知识,如何完成 SICP 练习 1.45(制作第 n 个根函数)?
- python - IndexError:使用 For 循环时 Python 3 中的列表索引超出范围
- javascript - 从 C# 在 JavaScript 中生成 Rfc2898DeriveBytes 键
- java - Micronaut JSON 序列化 - 使用 getter 而不是字段
- terraform - Terraform remote-exec 永远创建
- javascript - 在 Angular 中创建允许组件覆盖多个部门的网格系统的想法