番号を入力し、reCAPTCHA ウィジェットにチェックを入れ送信すると
reCAPTCHA client element has been removedといったエラーになり送れません。
コンソールで番号認証は有効にしてあります。
React
1import React from 'react'; 2import firebase from '../firebase'; 3import '../PhoneCheck.css'; 4 5class PhoneCheck extends React.Component { 6 constructor(props) { 7 super(props); 8 this.state = { 9 phone: '', 10 }; 11 } 12 13 componentDidMount() { 14 if (window.appVerifier && this.recaptchaWrapperRef) { 15 alert("通過"); 16 window.appVerifier.clear(); 17 this.recaptchaWrapperRef.innerHTML = `<div id="recaptcha-container"></div>` 18 } 19 20 window.appVerifier = new firebase.auth.RecaptchaVerifier( 21 "recaptcha-container", 22 { 23 size:"normal", 24 'callback': function(token) { 25 console.log(token); 26 }, 27 'expired-callback': function() { 28 console.log("コール"); 29 } 30 } 31 ); 32 window.appVerifier.render().then(function() { 33 window.appVerifier.verify(); 34 }); 35 } 36 37 handleToPhoneAuth = () => { 38 const { phone } = this.state; 39 if (phone === '') { 40 return; 41 } 42 43 44 firebase 45 .auth() 46 .signInWithPhoneNumber("+818012345678", window.appVerifier) 47 .then(confirmResult => { 48 alert("成功"); 49 }) 50 .catch(error => { 51 alert(error.message); 52 }); 53 this.props.history.push('/phoneauth'); 54 } 55 56 handleChange = (event) => { 57 this.setState({phone: event.target.value}); 58 } 59 60 render() { 61 let wh = window.innerHeight + 'px'; 62 let wrapperStyle = { 63 height: wh 64 }; 65 const { phone } = this.state; 66 67 return( 68 <div className="PhoneCheck-page" style={wrapperStyle}> 69 <div className="PhoneCheck-container"> 70 <div className="PhoneCheck-center"> 71 <input 72 className="PhoneCheck-input" 73 type="text" 74 value={phone} 75 placeholder="08012345678" 76 onChange={this.handleChange} 77 /> 78 <div ref={ref => this.recaptchaWrapperRef = ref}> 79 <div id="recaptcha-container"></div> 80 </div> 81 <div className="PhoneCheck-caption">SMSで認証コードを送信します</div> 82 <div className="PhoneCheck-btn" onClick={this.handleToPhoneAuth}>送信</div> 83 </div> 84 </div> 85 </div> 86 ); 87 } 88} 89 90export default PhoneCheck; 91
回答1件
あなたの回答
tips
プレビュー