I am trying to use rich-markdown-editor to get values but the method am using is not modular. Can someone suggest a better way. I have tried both onChange and onSave but cannot seem to get them to work.According to their documentation
onSave({ done: boolean }): void This callback is triggered when the user explicitly requests to save using a keyboard shortcut, Cmd+S or Cmd+Enter. You can use this as a signal to save the document to a remote server.
onChange(() => value): void This callback is triggered when the contents of the editor changes, usually due to user input such as a keystroke or using formatting options. You may use this to locally persist the editors state.
import React, { useState } from "react";
import Editor from "rich-markdown-editor";
const Whiteboard = () => {
const [content, setContent] = useState("");
return (
<div>
<div>
<h1>Your Content</h1>
<Editor id="123" value={content} onChange={setContent} />
</div>
{content}
</div>
);
};
export default Whiteboard;
useStateis for preserving data within your application, i.e. so that you can reference it from different functions (using thecontentvariable). Saving that variable to a database like SQL would be a different task; there are lots of great answers here already about how to do that.