ghost-portal/packages/page-tech-comm/src/useCounter.ts
Jaco 4929b1c6fd
Update headers for 2023 (#8665)
* Update headers for 2023

* Adjust env-config
2023-01-01 10:32:05 +02:00

20 lines
586 B
TypeScript

// Copyright 2017-2023 @polkadot/app-tech-comm authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Hash } from '@polkadot/types/interfaces';
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
const OPT = {
transform: (proposals: Hash[]) => proposals.length
};
function useCounterImpl (): number {
const { api, isApiReady } = useApi();
const counter = useCall<number>(isApiReady && api.derive.technicalCommittee?.proposals, undefined, OPT) || 0;
return counter;
}
export default createNamedHook('useCounter', useCounterImpl);