我有一个React组件,在 re-captcha 得到解决并触发回调后,下面会发送 OTP 。但是回调似乎没有触发。
import React from 'react';
import firebase from 'firebase/app';
import 'firebase/auth';
const firebaseConfig = {
apiKey: 'xxx',
authDomain: 'xxx',
databaseURL: 'xxx',
projectId: 'xxx',
storageBucket: 'xxx',
messagingSenderId: 'xxx',
appId: 'xxx',
measurementId: 'xxx',
};
firebase.initializeApp(firebaseConfig);
function App() {
const handleSubmit = event => {
event.preventDefault();
window.reCaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', {
size: 'invisible',
callback: function (response) {
// callback is not being fired
},
});
};
return (
<form onSubmit={handleSubmit}>
<input />
<button id="sign-in-button">Submit</button>
</form>
);
}
export default App;
根据文档,将触发回调,我们可以在其中调用该函数以发送OTP。