Building like component - onClick function giving error

Have a look at this thread, it describes the same problem.

According to the official github of react icons, you should instead use the onClick property of the parent. You can for example wrap it into a button:

 return (
    <button className={styles.containerButton} onClick={handleClick}>
      {liked && <AiFillHeart color="#ff6b81" size="20" />}
      {!liked && <AiOutlineHeart color="#ff6b81" size="20" />}
    </button>
  );

And it the CSS, do:

.containerButton {
    border: none;
    background-color: transparent;
}