Skip to content

Commit

Permalink
fix hook dependency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-1979 committed Jul 10, 2024
1 parent f118835 commit a2f2087
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions packages/dapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ export default function App() {
ApiPromise.create({ provider: wsProvider }).then(setApi);
}, [endpoint]);

useEffect(() => {
handleEnable();
}, [hasFlaskDetected]);

useEffect(() => {
/** To get the snap account */
extensions?.length &&
Expand All @@ -98,18 +94,6 @@ export default function App() {
}
}, [account, chainName]);

const handleInstallClick = useCallback(() => {
if (hasFlaskDetected === false) {
const FLASK_URL = 'https://chromewebstore.google.com/detail/metamask-flask-developmen/ljfoeinjpaedjfecbmggjgodbgkmjkjk';

window.open(FLASK_URL, '_blank');

return;
}

handleEnable();
}, [hasFlaskDetected]);

const handleEnable = useCallback(() => {
hasFlaskDetected && web3Enable('snap-only')
.then((ext: InjectedExtension[] | undefined) => {
Expand All @@ -122,6 +106,21 @@ export default function App() {
});
}, [hasFlaskDetected]);

useEffect(() => {
hasFlaskDetected && handleEnable();
}, [hasFlaskDetected, handleEnable]);

const handleInstallClick = useCallback(() => {
if (hasFlaskDetected === false) {
const FLASK_URL = 'https://chromewebstore.google.com/detail/metamask-flask-developmen/ljfoeinjpaedjfecbmggjgodbgkmjkjk';

window.open(FLASK_URL, '_blank');

return;
}

handleEnable();
}, [hasFlaskDetected , handleEnable]);

useEffect(() => {
hasFlask().then(setHasFlask)
Expand Down

0 comments on commit a2f2087

Please sign in to comment.