Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { lazy, Suspense, useEffect, useState } from "react";
|
||||
|
||||
import type { MonacoAutoCompletion, MonacoEditorClientProps } from "./MonacoEditor.client";
|
||||
|
||||
const MonacoEditorClient = lazy(() => import("./MonacoEditor.client"));
|
||||
|
||||
export type { MonacoAutoCompletion };
|
||||
|
||||
export default function MonacoEditor(props: MonacoEditorClientProps) {
|
||||
// The editor is strictly client-only: ./MonacoEditor.client pulls in the
|
||||
// browser-only monaco runtime, so importing it during SSR throws and the
|
||||
// streaming render sets HTTP 500 on every page that mounts an editor (the page
|
||||
// still hydrates fine on the client, which is why this stayed invisible until a
|
||||
// readiness test asserted the response status). Render the placeholder on the
|
||||
// server AND the first client render — keeping markup identical so hydration
|
||||
// matches — then swap in the real editor after mount, so the client bundle is
|
||||
// the only place that ever imports it.
|
||||
const [mounted, setMounted] = useState(false);
|
||||
useEffect(() => setMounted(true), []);
|
||||
|
||||
if (!mounted) {
|
||||
return <div className={props.className} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Suspense fallback={<div className={props.className} />}>
|
||||
<MonacoEditorClient {...props} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user