We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7d8705 commit c1fe913Copy full SHA for c1fe913
electron/renderer/components/no-ssr/index.ts
@@ -0,0 +1 @@
1
+export * from './no-ssr';
electron/renderer/components/no-ssr/no-ssr.tsx
@@ -0,0 +1,19 @@
+import dynamic from 'next/dynamic';
2
+import type { ReactNode } from 'react';
3
+
4
+/**
5
+ * Force a component to not be rendered on the server.
6
+ *
7
+ * In JSX, to differentiate the generic `<P>` from an HTML tag
8
+ * then we append a trailing comma as `<P,>`.
9
+ */
10
+const NoSSR = <P,>(
11
+ component: React.FC<P> | ReactNode
12
+): React.ComponentType<P> => {
13
+ if (typeof component === 'function') {
14
+ return dynamic(async () => component, { ssr: false });
15
+ }
16
+ return NoSSR(() => component);
17
+};
18
19
+export { NoSSR };
0 commit comments