ghost-portal/packages/test-support/src/react/apiInTests.ts
2021-01-03 11:33:39 +01:00

13 lines
390 B
TypeScript

// Copyright 2017-2021 @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;
};