<head>
  <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
</head>
<div id="root">
  <!-- This div's content will be managed by React. -->
</div>
body {
  margin-top: 60px;
  font-family: 'Montserrat', sans-serif;
  text-align: center;
}

div {
  margin-top: 45px;
}


.mood {
  font-size: 60px;
  background: orange;
  border-radius: 10px;
  margin: 10px;
  padding: 10px;
  
}

.mood:hover {
  background: tomato;
}


p {
  margin: 4em;
  font-size: 25px;
}
const {useState, useEffect} = React;

function App () {
  
  const [ mood, setMood] = useState("");
  const [ message, setMessage] = useState("");
  
  const moods  = [
               
                  {mood: "happy", message: "Share your joy with others  💃 🎉🕺", emoticon: "😁"}, 
                  {mood: "angry", message:"Relax...just breathe 🧘🏽‍♀️🧘🏻‍♂️", emoticon: "😠"},
                  {mood: "sad",   message:"Listen to your favorite song  🎧 🎼", emoticon: "😢" },
                  {mood:"bored", message: "Read a book, Go for a walk 🏃🏻‍♀️📕  📖", emoticon: "😒"}]

  
  const handleMood = (e) =>{
    setMood(e.target.value);
  }
  
  useEffect(() => {
   if (mood.length > 0) {
    setMessage(moods.filter( item => item.mood === mood)[0].message)  
    }
  }, [mood]);
  
  return(
   <div>
    <h1>What is your mood today?</h1>  
      <div>
         {moods.map( item =>
           <button onClick={handleMood} value={item.mood} className="mood">{item.emoticon} </button>
          )}
      </div>
      <p> {message} </p>
    </div>
  )
}



ReactDOM.render(
  <App/>,
  document.getElementById('root')
);
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.6/umd/react-dom.production.min.js