我有这个 firebase 方法,它使用电子邮件和密码创建一个 firebase 用户
async register(name, email, password,type) {
let id;
const createUser = this.functions.httpsCallable('createUser');
return await this.auth.createUserWithEmailAndPassword({email,password })
.then((newUser)=>{
id = newUser.user.uid;
newUser.user.updateProfile({
displayName: name
})
})
.then(()=>{
createUser({
id:id,
name:name,
email:email,
type:type
})
})
}
Run Code Online (Sandbox Code Playgroud)
它还使用获取用户详细信息和用户类型的云功能将用户添加到 Firestore 集合中。
我有3个承诺(
createUserWithEmail...()updateUserProfile()1createUser()) 彼此依赖.. 如何在一个函数中使用它们?
注意:functions.auth.user().onCreate()由于用户类型字段,无法使用该方法
如何在不使用 的情况下编写此方法.then()?一些用户没有出现在数据库中
javascript firebase firebase-authentication google-cloud-functions google-cloud-firestore
没有 react-paypal-button-v2 ~~~有 60KB 的开销
类似的问题在这里,但他们建议react-paypal-button-v2
我正在尝试制作一个 React PayPal 按钮来更改道具更改的账单金额。
我使用道具价格调用以下组件,每次价格更改时,我都想重新渲染按钮以更新实际价格。没有 react-paypal-button-v2
const PaypalForm = props => {
let paypalRef = useRef();
useEffect(() => {
window.paypal
.Buttons({
createOrder: (data, actions) => {
return actions.order.create({
purchase_units: [
{
description: "test",
amount: {
currency_code: "USD",
value: props.price
}
}
]
});
},
onApprove: async (data, actions) => {
const order = await actions.order.capture();
console.log(order);
},
onError: err => {
setError(err);
console.error(err);
}
})
.render(paypalRef.current);
}, [props.price]);
return ( …Run Code Online (Sandbox Code Playgroud)