ghost-portal/packages/page-tech-comm/src/useCounter.ts
Jaco c55a15dc53
Extract Latency/API stats reusable chart (#7679)
* Extract Latency/API stats reusable chart

* Adjust
2022-06-02 11:54:47 +03:00

20 lines
586 B
TypeScript

// Copyright 2017-2022 @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);