When I was working on creating a text input space using the input type area and utilizing the onChange utility, everything was running smoothly.
Now, my task is to incorporate an emoji bar and insert a specific emoji into the input space upon clicking it. Essentially, I am attempting to append or concatenate the emoji to the variable set as new_chat.
https://i.sstatic.net/XITSMYXc.png
Here are the set variables:
const [chats, setchat] = useState([]);
const [new_chat, set_new_chat] = useState([]);
Functions for managing chats:
function handlechat(event){
set_new_chat(event.target.value);
}
function add_chat(){
if(new_chat.trim()!=""){
setchat(c => [...c, {text: new_chat, time: new Date()}]);
set_new_chat("");
// settime(t => [...t, new Date()]);
console.log("new chat added");
}
}
Input text code:
<input type="text" id="input_text" value={new_chat} onChange={handlechat}></input>
Snippet for adding emojis:
<div className="emoji_container" style={{fontSize: "1.5em"}} onClick={new_chat.concat('👍')}>👍</div>
I would greatly appreciate any assistance!
I am currently struggling with incorporating emojis from an emoji panel into an input box.