21 lines
588 B
TypeScript
21 lines
588 B
TypeScript
// Copyright 2017-2023 @polkadot/app-bounties authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { DeriveBounties } from '@polkadot/api-derive/types';
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
|
|
|
|
function useCounterImpl (): number {
|
|
const { api, isApiReady } = useApi();
|
|
const bounties = useCall<DeriveBounties>(isApiReady && api.derive.bounties?.bounties);
|
|
|
|
return useMemo(
|
|
() => bounties?.length || 0,
|
|
[bounties]
|
|
);
|
|
}
|
|
|
|
export default createNamedHook('useCounter', useCounterImpl);
|