18 lines
542 B
TypeScript
18 lines
542 B
TypeScript
// Copyright 2017-2021 @polkadot/app-democracy authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { Hash } from '@polkadot/types/interfaces';
|
|
|
|
import { useApi, useCall } from '@polkadot/react-hooks';
|
|
|
|
const transformCounter = {
|
|
transform: (proposals: Hash[]) => proposals.length
|
|
};
|
|
|
|
export default function useCounter (): number {
|
|
const { api, isApiReady } = useApi();
|
|
const counter = useCall<number>(isApiReady && api.query.technicalCommittee?.proposals, undefined, transformCounter) || 0;
|
|
|
|
return counter;
|
|
}
|