ant-design/.dumi/theme/common/ClientOnly.tsx
lijianan 371c10c01f
site: update dumi type (#47326)
* site: update dumi type

* fix: fix

* fix: fix

* fix: fix

* fix: fix
2024-02-04 17:08:39 +08:00

15 lines
383 B
TypeScript

import type React from 'react';
import { useLayoutEffect, useState } from 'react';
const ClientOnly: React.FC<React.PropsWithChildren> = ({ children }) => {
const [clientReady, setClientReady] = useState<boolean>(false);
useLayoutEffect(() => {
setClientReady(true);
}, []);
return clientReady ? (children as React.ReactElement) : null;
};
export default ClientOnly;