Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor wrapped in pre? #424

Closed
amolpatel opened this issue Aug 8, 2022 · 6 comments
Closed

Editor wrapped in pre? #424

amolpatel opened this issue Aug 8, 2022 · 6 comments

Comments

@amolpatel
Copy link

For some reason, the editor is wrapped in a pre and I can't find anywhere to disable that in the props. I'm using NextJS and tailwind. I followed the instructions on how to install using Next. Any help would be appreciated!

CleanShot 2022-08-08 at 14 00 21@2x

Rendered HTML:
CleanShot 2022-08-08 at 14 03 34@2x

React code:

import "@uiw/react-markdown-preview/markdown.css";
import "@uiw/react-md-editor/markdown-editor.css";
import dynamic from "next/dynamic";
import React from "react";

interface Props {
  value: string;
  onChange: (value: string) => void;
}

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

export default function MarkdownEditor({ value, onChange }: Props): JSX.Element {
  return (
    <div className="container">
      <MDEditor value={value} onChange={(text) => onChange(text ?? "")} />
    </div>
  );```
@dukesx
Copy link

dukesx commented Aug 8, 2022

@amolpatel do you have any issue with editor reloading on state change ?

@amolpatel
Copy link
Author

@dukesx nope, I don't think so

@dukesx
Copy link

dukesx commented Aug 8, 2022

@amolpatel strangely , whenever i enter a value inside the editor, the damn thing just resets itself, like the state, its like the state change triggers it to reset for some reason

@nickscamara
Copy link

Happening to me as well. @amolpatel what was the fix?

@amolpatel
Copy link
Author

@nickscamara You just need to re-render the textarea:

<MDEditor
    value={value}
    onChange={(text) => onChange(text ?? "")}
    components={{
      textarea: (props) => {
        return (
          // @ts-ignore
          <textarea {...props} />
        );
      },
    }}
  />

@nickscamara
Copy link

@amolpatel Thank you very much. That and upgrading to the latest version fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants