From 00f3dfe7efbc486a5821b038d089dca557fdd778 Mon Sep 17 00:00:00 2001 From: "Marshall T. Rose" Date: Tue, 3 Oct 2023 14:02:09 -0400 Subject: [PATCH] possibly fix `useEffect` lint messages Still don't have a fix for ```/Users/mrose/Downloads/brave/brave-talk/src/components/web3/crypto/CryptoWrapper.tsx 54:9 warning The 'fetchCurrentAddress' function makes the dependencies of useEffect Hook (at line 64) change on every render. To fix this, wrap the definition of 'fetchCurrentAddress' in its own useCallback() Hook react-hooks/exhaustive-deps``` as `fetchCurrentAddress` is `async` --- src/components/web3/crypto/CryptoOOBPopup.tsx | 7 ++++++- src/components/web3/crypto/CryptoSendPopup.tsx | 2 +- src/components/web3/crypto/CryptoWrapper.tsx | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/web3/crypto/CryptoOOBPopup.tsx b/src/components/web3/crypto/CryptoOOBPopup.tsx index 333743e4..f3d7aebf 100644 --- a/src/components/web3/crypto/CryptoOOBPopup.tsx +++ b/src/components/web3/crypto/CryptoOOBPopup.tsx @@ -116,7 +116,12 @@ export const CryptoOOBPopup: React.FC = ({ } else { setShowing(false); } - }, [currentResolution]); + }, [ + currentResolution, + outstandingRequests, + setShowing, + setCurrentResolution, + ]); return (
diff --git a/src/components/web3/crypto/CryptoSendPopup.tsx b/src/components/web3/crypto/CryptoSendPopup.tsx index c6fea285..abe87d17 100644 --- a/src/components/web3/crypto/CryptoSendPopup.tsx +++ b/src/components/web3/crypto/CryptoSendPopup.tsx @@ -124,7 +124,7 @@ export const CryptoSendPopup: React.FC = ({ } else { setShowing(false); } - }, [pending]); + }, [pending, jitsi]); return (
diff --git a/src/components/web3/crypto/CryptoWrapper.tsx b/src/components/web3/crypto/CryptoWrapper.tsx index e09688dc..3a50b937 100644 --- a/src/components/web3/crypto/CryptoWrapper.tsx +++ b/src/components/web3/crypto/CryptoWrapper.tsx @@ -61,9 +61,9 @@ export const CryptoWrapper: React.FC = ({ }; useEffect(() => { fetchCurrentAddress(); - }, []); + }, [fetchCurrentAddress]); - const initializeCryptoAction = () => { + const initializeCryptoAction = useCallback(() => { cryptoAction.addOutstandingRequest = (params: CryptoTransactionParams) => { setOutstandingRequests(outstandingRequests.concat(params)); }; @@ -97,11 +97,11 @@ export const CryptoWrapper: React.FC = ({ ); }; cryptoAction.isInit = true; - }; + }, [incomingRequests, outstandingRequests]); initializeCryptoAction(); useEffect(() => { initializeCryptoAction(); - }, []); + }, [initializeCryptoAction]); return (