Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add an emoji button in react?

So I already did this basically 1 year ago but I forgot how to do it, and its not working now though. Here is the LINK
basically I have a like a "smile emoji icon button" and then when I click it I will pass the emoji in my text but it giving me now an error undefined. In the link you can see that it has same thing here.

import './App.scss';
import React, { useState } from 'react'
import 'bootstrap/dist/css/bootstrap.min.css';
import Picker from 'emoji-picker-react';

function App() {



    const [chosenEmoji, setChosenEmoji] = useState(null);

    const onEmojiClick = (event, emojiObject) => {
      setChosenEmoji(emojiObject);
      console.log(emojiObject)
    };
  
    
    return (
      <div className="App">
        <header className="App-header">
          
        {/* {isLogin && user ? <LoginTrue/> : <LoginFalse/>} */}
        {chosenEmoji ? (
          <span>You chose: {chosenEmoji.emoji}</span>
        ) : (
          <span>No emoji Chosen</span>
        )}
        <Picker onEmojiClick={onEmojiClick} />
      
        </header>
      </div>
    );
}

export default App;

but the new update of emoji-picker-react did get different…Is anyone can give me an idea of it? or is there another source of importing emojis..I don’t want to use Input-emoji-react its too ugly.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You may find it helpful but the way I personally did it on my project were I also used emoji-picker-react and MaterialUI is through native materialUI emoji icon button like this:

<div className="chat_footer">
        {!emojiPicker ? (
          <InsertEmoticonIcon onClick={() => setEmojiPicker((prev) => !prev)} />
        ) : (
          <>
            <InsertEmoticonIcon
              onClick={() => setEmojiPicker((prev) => !prev)}
            />
            <EmojiPicker
              searchDisabled="true"
              previewConfig={{ showPreview: false }}
              emojiStyle="google"
              onEmojiClick={(e) => setInput((input) => input + e.emoji)}
              height={400}
              width="40%"
            />
          </>
        )}

As I said, InsertEmoticonIcon is a MaterialUI icon which I import

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading