Skip to content

Commit

Permalink
possibly fix useEffect lint messages
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
mrose17 committed Oct 3, 2023
1 parent 2bf55d1 commit 00f3dfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/components/web3/crypto/CryptoOOBPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ export const CryptoOOBPopup: React.FC<CryptoOOBPopupProps> = ({
} else {
setShowing(false);
}
}, [currentResolution]);
}, [
currentResolution,
outstandingRequests,
setShowing,
setCurrentResolution,
]);

return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/web3/crypto/CryptoSendPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const CryptoSendPopup: React.FC<CryptoSendPopupProps> = ({
} else {
setShowing(false);
}
}, [pending]);
}, [pending, jitsi]);

return (
<div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/web3/crypto/CryptoWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export const CryptoWrapper: React.FC<CryptoWrapperProps> = ({
};
useEffect(() => {
fetchCurrentAddress();
}, []);
}, [fetchCurrentAddress]);

const initializeCryptoAction = () => {
const initializeCryptoAction = useCallback(() => {
cryptoAction.addOutstandingRequest = (params: CryptoTransactionParams) => {
setOutstandingRequests(outstandingRequests.concat(params));
};
Expand Down Expand Up @@ -97,11 +97,11 @@ export const CryptoWrapper: React.FC<CryptoWrapperProps> = ({
);
};
cryptoAction.isInit = true;
};
}, [incomingRequests, outstandingRequests]);
initializeCryptoAction();
useEffect(() => {
initializeCryptoAction();
}, []);
}, [initializeCryptoAction]);
return (
<div>
<CryptoRecievePopup
Expand Down

0 comments on commit 00f3dfe

Please sign in to comment.