Skip to content

Commit

Permalink
fix: rename async
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Oct 16, 2023
1 parent 943f03a commit 6330211
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
'react/jsx-max-props-per-line': 'off',
'react-hooks/exhaustive-deps': [
'warn', {
'additionalHooks': '(useAsync)'
'additionalHooks': '^useAsyncTrigger$'
}
]
}
Expand Down
7 changes: 4 additions & 3 deletions apps/common/hooks/useAsyncEffect.ts
Original file line number Diff line number Diff line change
@@ -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<void>, deps: DependencyList): () => Promise<void> {
//Should be useAsyncEffect, but exhaustive-deps is messing with this.
function useAsyncTrigger(effect: () => Promise<void>, deps: DependencyList): () => Promise<void> {
const asyncEffectInCallback = useCallback(async (): Promise<void> => {
effect();
}, [...deps]);
Expand All @@ -15,4 +16,4 @@ function useAsync(effect: () => Promise<void>, deps: DependencyList): () => Prom
}


export {useAsync};
export {useAsyncTrigger};
8 changes: 4 additions & 4 deletions apps/veyfi/contexts/useGauge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check failure on line 11 in apps/veyfi/contexts/useGauge.tsx

View workflow job for this annotation

GitHub Actions / Test Build

Cannot find module '@common/hooks/useAsyncTrigger' or its corresponding type declarations.
import {keyBy} from '@common/utils';

import type {ReactElement} from 'react';
Expand Down Expand Up @@ -72,7 +72,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr
// toAddress('0x9Cb511D44930c0C3D3114FFAaBedC3e0876D791a')
// ];

const refreshVotingEscrow = useAsync(async (): Promise<void> => {
const refreshVotingEscrow = useAsyncTrigger(async (): Promise<void> => {
const gaugeAddresses = [
toAddress('0xbADfbF563C6C85F76e086E7a1915A1A46d683810'),
toAddress('0xd5947C01dBaEFeFF05186FE34A976b2E28d90542'),
Expand Down Expand Up @@ -104,7 +104,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr
set_gauges(allGauges);
}, []);

const refreshAllowances = useAsync(async (): Promise<void> => {
const refreshAllowances = useAsyncTrigger(async (): Promise<void> => {
if (!gauges || !address) {
return;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr
set_allowancesMap(_allowancesMap);
}, [address, gauges]);

const refreshPositions = useAsync(async (): Promise<void> => {
const refreshPositions = useAsyncTrigger(async (): Promise<void> => {
if (!gauges || !isActive || !address) {
return;
}
Expand Down

0 comments on commit 6330211

Please sign in to comment.