我有一个更新用户个人资料图片的组件:
const Updater = () => {
const updateProfilePic = async (photoURL) => {
await auth.currentUser.updateProfile({ 'photoURL': photoURL });
}
}
我有第二个组件检测用户状态的变化:
const StateChangesDetector = () => {
auth.onAuthStateChanged( user => {
if(user)
console.log('User changed state', JSON.stringify(user));
});
}
问题是auth.onAuthStateChanged()执行后没有触发updateProfile()。因此,我得到了旧用户的状态和旧的个人资料图片。
auth.onAuthStateChanged()更新用户头像后如何强制触发?