sjdemartini / mui-tiptap

A Material UI (MUI) styled WYSIWYG rich text editor, using Tiptap
MIT License
319 stars 43 forks source link

Controlled Component #195

Closed dkang23 closed 9 months ago

dkang23 commented 9 months ago

You can use this easily as a controlled component like this

  const [content, setContent] = useState('');

  useEffect(() => {
   setContent(<p>Some saved content</p>)
  }, []);

<RichTextEditor
  content={content}
        onUpdate={({ editor }) => {
          setContent(editor.getHTML());
        }}
        />
sjdemartini commented 9 months ago

@dkang23 I'm not sure I understand why you've filed this issue. Is there some problem you're encountering?

For what it's worth, I have a section of the README that goes into detail how to handle this scenario: https://github.com/sjdemartini/mui-tiptap/blob/013d839480df26182cded190cad4eb2f8b47ead0/README.md#re-rendering-richtexteditor-when-content-changes

It's generally not a good idea to set things up as you have them shown above, for the reasons mentioned in the README.

sjdemartini commented 9 months ago

Closing as not planned per the above comment, but let me know if there's any remaining issue