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

How to clear the text in textarea #54

Open
yongxinxu opened this issue May 3, 2021 · 1 comment
Open

How to clear the text in textarea #54

yongxinxu opened this issue May 3, 2021 · 1 comment

Comments

@yongxinxu
Copy link

I am trying to clear the text in mention's textarea by javascript in React. I have tried

const textarea = document.getElementById("id");
textarea.value = "";

but this doesn't work for me.

@schmoninator
Copy link

You can do this:

inputRef.current.setState({ ...inputRef.current.state, value: "" });

For this to work, you have to have set

import React, { useRef } from 'react';
const inputRef = useRef<Mentions>(null);
...
<Mentions
   ref={inputRef}
   ....

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

2 participants