ghost-portal/packages/test-support/src/react/apiInTests.ts
2022-01-01 09:30:15 +02:00

13 lines
390 B
TypeScript

// Copyright 2017-2022 @polkadot/test-support authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React, { PropsWithChildren } from 'react';
import { useApi } from '@polkadot/react-hooks';
export const WaitForApi = ({ children }: { children: React.ReactNode }): PropsWithChildren<any> | null => {
const api = useApi();
return api.isApiReady ? (children) : null;
};