Hi I'm working on a user mention function now. I have a problem that I can't replace text
If I'm trying to find a user with "@" I can't find a user so that's why I replace text.
const handleInputComment = (e: React.ChangeEvent<HTMLInputElement>) => {
setCommentValue({ ...commentValue, comment: e.target.value });
e.target.value.split(" ").map((text) => {
if (text.startsWith("@")) {
text.replace("@", "");
setMentionSearchValue(text);
console.log(mentionSearchValue);
return setIsMentionModalOpen(true);
}
return setIsMentionModalOpen(false);
});
};
when I see the console.log what I will see like @asdfsdf @sadfasfsaf @asdfjaskfjfkjf
how to replace text? thanks for reading my question.