From 6330211ec70bd2007444719ba030071b03557d5d Mon Sep 17 00:00:00 2001 From: Majorfi Date: Mon, 16 Oct 2023 19:24:44 +0200 Subject: [PATCH] fix: rename async --- .eslintrc.js | 2 +- apps/common/hooks/useAsyncEffect.ts | 7 ++++--- apps/veyfi/contexts/useGauge.tsx | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1922058e9..451c82a9b 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,7 +19,7 @@ module.exports = { 'react/jsx-max-props-per-line': 'off', 'react-hooks/exhaustive-deps': [ 'warn', { - 'additionalHooks': '(useAsync)' + 'additionalHooks': '^useAsyncTrigger$' } ] } diff --git a/apps/common/hooks/useAsyncEffect.ts b/apps/common/hooks/useAsyncEffect.ts index 76fb7d76f..7f68c07fe 100644 --- a/apps/common/hooks/useAsyncEffect.ts +++ b/apps/common/hooks/useAsyncEffect.ts @@ -1,8 +1,9 @@ /* eslint-disable react-hooks/exhaustive-deps */ -import {type DependencyList, useCallback,useEffect} from 'react'; +import {type DependencyList, useCallback, useEffect} from 'react'; -function useAsync(effect: () => Promise, deps: DependencyList): () => Promise { +//Should be useAsyncEffect, but exhaustive-deps is messing with this. +function useAsyncTrigger(effect: () => Promise, deps: DependencyList): () => Promise { const asyncEffectInCallback = useCallback(async (): Promise => { effect(); }, [...deps]); @@ -15,4 +16,4 @@ function useAsync(effect: () => Promise, deps: DependencyList): () => Prom } -export {useAsync}; +export {useAsyncTrigger}; diff --git a/apps/veyfi/contexts/useGauge.tsx b/apps/veyfi/contexts/useGauge.tsx index 6e000de6a..99a642bfd 100644 --- a/apps/veyfi/contexts/useGauge.tsx +++ b/apps/veyfi/contexts/useGauge.tsx @@ -8,7 +8,7 @@ import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {allowanceKey, toAddress} from '@yearn-finance/web-lib/utils/address'; import {decodeAsAddress, decodeAsBigInt, decodeAsNumber, decodeAsString} from '@yearn-finance/web-lib/utils/decoder'; import {toNormalizedBN} from '@yearn-finance/web-lib/utils/format.bigNumber'; -import {useAsync} from '@common/hooks/useAsyncEffect'; +import {useAsyncTrigger} from '@common/hooks/useAsyncTrigger'; import {keyBy} from '@common/utils'; import type {ReactElement} from 'react'; @@ -72,7 +72,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr // toAddress('0x9Cb511D44930c0C3D3114FFAaBedC3e0876D791a') // ]; - const refreshVotingEscrow = useAsync(async (): Promise => { + const refreshVotingEscrow = useAsyncTrigger(async (): Promise => { const gaugeAddresses = [ toAddress('0xbADfbF563C6C85F76e086E7a1915A1A46d683810'), toAddress('0xd5947C01dBaEFeFF05186FE34A976b2E28d90542'), @@ -104,7 +104,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr set_gauges(allGauges); }, []); - const refreshAllowances = useAsync(async (): Promise => { + const refreshAllowances = useAsyncTrigger(async (): Promise => { if (!gauges || !address) { return; } @@ -136,7 +136,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr set_allowancesMap(_allowancesMap); }, [address, gauges]); - const refreshPositions = useAsync(async (): Promise => { + const refreshPositions = useAsyncTrigger(async (): Promise => { if (!gauges || !isActive || !address) { return; }