uiwjs / react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-md-editor
MIT License
2.17k stars 156 forks source link

Doesn't work with typescript #379

Open bebru2k1 opened 2 years ago

bebru2k1 commented 2 years ago

I don't understand why it doesn't work with typescript

image

jaywcjlove commented 2 years ago

@bebru2k1 Example: https://codesandbox.io/embed/objective-antonelli-kkojbl?fontsize=14&hidenavigation=1&theme=dark

It works fine.

import { useState } from "react";
import MDEditor from "@uiw/react-md-editor";

const mkdStr = `
\`\`\`javascript
import React from "react";
import ReactDOM from "react-dom";
import MEDitor from '@uiw/react-md-editor';

\`\`\`
`;
export default function App() {
  const [value, setValue] = useState(mkdStr);
  return (
    <div className="App">
      <h3>Auto</h3>
      <MDEditor
        height={200}
        value={value}
        onChange={(value = "") => {
          setValue(value);
        }}
      />
    </div>
  );
}
bebru2k1 commented 2 years ago

i am using nextjs

const MDEditor = dynamic(
  () => import("@uiw/react-md-editor").then((mod) => mod.default),
  { ssr: false }
);

but i changed and it works fine

const MDEditor = dynamic(
  () => import("@uiw/react-md-editor"),
  { ssr: false }
);
jothinayagan-psi commented 1 year ago

@bebru2k1 I'm also using the same in next.js. But unable to run the same in jest test. Getting the error. Any solution on this?

image