[英]Uncaught TypeError: Cannot read properties of null (reading 'uid'). Trying to get the currentUser.uid
auth.currentUser.uid
不是useEffect
的依賴項。 這意味着此 Value 的更改永遠不會觸發useEffect
。
關於useEffect
的一件事是它不僅會在依賴項更新時觸發,還會在組件掛載時觸發。 這意味着它會在你的 auth state 設置之前觸發。
您應該將auth.currentUser?.uid
設置為依賴項,並檢查 currentUser 在useEffect
中是否有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.