Open pccai opened 1 year ago
`//import MDEditor from '@uiw/react-md-editor'; const MarkdownPreview = React.lazy(() => import("@uiw/react-markdown-preview"));
return (
import React, { Suspense } from "react";
import ReactDOM from "react-dom";
const MarkdownPreview = React.lazy(() => import("@uiw/react-markdown-preview"));
const MarkdownEditPreview = React.lazy(async () => {
const mdx = await import("@uiw/react-md-editor");
console.log("mdx:", mdx, mdx.default.Markdown);
return {
default: mdx.default.Markdown
};
});
function App() {
return (
<div className="container">
<Suspense fallback={<div>loading...</div>}>
<MarkdownPreview source="## Hello World" />
</Suspense>
<Suspense fallback={<div>loading...</div>}>
<MarkdownEditPreview source="## Hello World" />
</Suspense>
</div>
);
}
ReactDOM.render(<App />, document.getElementById("container"));
import React, { Suspense } from "react"; import ReactDOM from "react-dom"; const MarkdownPreview = React.lazy(() => import("@uiw/react-markdown-preview")); const MarkdownEditPreview = React.lazy(async () => { const mdx = await import("@uiw/react-md-editor"); console.log("mdx:", mdx, mdx.default.Markdown); return { default: mdx.default.Markdown }; }); function App() { return ( <div className="container"> <Suspense fallback={<div>loading...</div>}> <MarkdownPreview source="## Hello World" /> </Suspense> <Suspense fallback={<div>loading...</div>}> <MarkdownEditPreview source="## Hello World" /> </Suspense> </div> ); } ReactDOM.render(<App />, document.getElementById("container"));
thanks this worked
`const MDEditor = React.lazy(() => import('@uiw/react-md-editor')); ......
`
Compilation Error in MDEditor.Markdown
declare type Editor = React.FC<PropsWithRef<MDEditorProps>> & { Markdown: typeof MarkdownPreview; };