mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-29 18:50:00 +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;
|