我正在尝试通过电话注册,但是我得到了一个错误:TypeError不是一个对象(计算'_this.state.confirm.confirm')。这是什么原因呢?
import auth from '@react-native-firebase/auth';
class PhoneVerificationPart extends Component {
constructor(props) {
super(props);
this.state = {
confirm: null,
code: null
};
}
signInWithPhoneNumber = async (+90....) => {
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
this.setState({
confirm: confirmation
})
}
confirmCode = async () => {
try {
await this.state.confirm.confirm(this.state.code)
await this.props.closeAndCreateCustomer()
} catch (error) {
console.log(error)
}
} }发布于 2020-12-01 16:38:12
当this.state.confirm最初被定义为null时,在它被重置之前,您将从该状态访问它。
使用这种方式
var phoneNumber = "+16505554567"; // should be in string
firebase.auth().signInWithPhoneNumber(phoneNumber)
.then(function (confirmationResult) {
// confirmationResult can resolve with the fictional testVerificationCode above.
return confirmationResult.confirm(testVerificationCode)
}).catch(function (error) {
// Error; SMS not sent
// ...
});https://stackoverflow.com/questions/65087110
复制相似问题