first commit
This commit is contained in:
20
calcom/packages/core/components/NoSSR.tsx
Normal file
20
calcom/packages/core/components/NoSSR.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode; // React.ReactNode
|
||||
fallback?: JSX.Element | null; // JSX.Element
|
||||
}
|
||||
|
||||
const NoSSR = ({ children, fallback = null }: Props) => {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
useEffect(() => setMounted(true), []);
|
||||
|
||||
if (!mounted) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export default NoSSR;
|
||||
Reference in New Issue
Block a user