mirror of
https://github.com/documenso/documenso.git
synced 2026-07-10 04:55:02 +10:00
24 lines
439 B
TypeScript
24 lines
439 B
TypeScript
import { useSyncExternalStore } from 'react';
|
|
|
|
const subscribe = () => {
|
|
return () => {};
|
|
};
|
|
|
|
const getSnapshot = () => {
|
|
return true;
|
|
};
|
|
|
|
const getServerSnapshot = () => {
|
|
return false;
|
|
};
|
|
|
|
export const ClientOnly = ({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}): React.ReactElement | null => {
|
|
const isClient = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
|
|
return isClient ? <>{children}</> : null;
|
|
};
|