mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-28 19:18:40 +08:00
371c10c01f
* site: update dumi type * fix: fix * fix: fix * fix: fix * fix: fix
15 lines
383 B
TypeScript
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;
|