-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Is it possible to have access to ref for textArea? #534
Comments
@ianfelix https://codesandbox.io/embed/markdown-editor-for-react-https-github-com-uiwjs-react-md-editor-issues-534-nmu6u9?fontsize=14&hidenavigation=1&theme=dark import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom";
import MDEditor from "@uiw/react-md-editor";
const mkdStr = `# Markdown Editor`;
function App() {
const [textarea, setTextarea] = useState();
const [value, setValue] = React.useState(mkdStr);
useEffect(() => {
console.log("$edit:12", textarea);
}, [textarea]);
function refCallback(node) {
if (node && node.textarea) {
setTextarea(node.textarea);
}
}
return (
<div className="container">
<h3>Auto</h3>
<MDEditor
ref={refCallback}
height={200}
value={value}
onChange={setValue}
/>
</div>
);
} |
jaywcjlove
added a commit
that referenced
this issue
Jun 1, 2023
@ianfelix Upgrade |
@ianfelix https://codesandbox.io/embed/misty-waterfall-485be5?fontsize=14&hidenavigation=1&theme=dark import React, { useEffect, useState } from "react";
import MDEditor, { RefMDEditor } from "@uiw/react-md-editor";
export default function App() {
const [textarea, setTextarea] = useState<HTMLTextAreaElement>();
const [value, setValue] = React.useState("# Markdown Editor");
useEffect(() => {
console.log("$edit:12", textarea);
}, [textarea]);
function refCallback(node: RefMDEditor) {
if (node && node.textarea) {
setTextarea(node.textarea);
}
}
return (
<div className="container">
<h3>Auto</h3>
<MDEditor
ref={refCallback}
height={200}
value={value}
onChange={(val) => {
setValue(val || "");
}}
/>
</div>
);
} |
wow, thank you!! you are doing an amazing work here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to have the control of the textArea input
The text was updated successfully, but these errors were encountered: