You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
436 B

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