19 lines
540 B
TypeScript
19 lines
540 B
TypeScript
// Copyright 2017-2024 @polkadot/app-democracy authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
|
|
|
|
function useCounterImpl (): number {
|
|
const { api, isApiReady } = useApi();
|
|
const proposalHashes = useCall<unknown[]>(isApiReady && api.derive.alliance.proposalHashes);
|
|
|
|
return useMemo(
|
|
() => proposalHashes?.length || 0,
|
|
[proposalHashes]
|
|
);
|
|
}
|
|
|
|
export default createNamedHook('useCounter', useCounterImpl);
|