Skip to content

Commit

Permalink
fix: error remove emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSantiagoValdivia committed Jun 7, 2023
1 parent f7e38c1 commit 1ee9cac
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions components/main/BodyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ const BodyWrapper = ({ selectedEmojis, setSelectedEmojis }) => {
}, [selectedEmojis]);

const handleRemoveEmoji = (emoji) => {
setSelectedEmojis(selectedEmojis.filter((selectedEmoji) => selectedEmoji !== emoji));
const updatedEmojis = [...selectedEmojis];
const index = updatedEmojis.indexOf(emoji);
if (index > -1) {
updatedEmojis.splice(index, 1);
setSelectedEmojis(updatedEmojis);
}
};

return (
Expand All @@ -33,18 +38,16 @@ const BodyWrapper = ({ selectedEmojis, setSelectedEmojis }) => {
) : (
<div className={styles.main}>
<div className={styles.selectedEmojiContainer}>
{selectedEmojis.map((emoji) => (
<div>
<span key={emoji} className={styles.emoji}>
{emoji}
</span>
{selectedEmojis.map((emoji, index) => (
<span className={styles.emoji} key={index}>
{emoji}
<button
className={styles.buttonRemove}
onClick={() => handleRemoveEmoji(emoji)}
>
<RiDeleteBinLine className={styles.icon}/>
<RiDeleteBinLine className={styles.icon} />
</button>
</div>
</span>
))}
</div>
{showAddEmojisText && (
Expand Down

1 comment on commit 1ee9cac

@vercel
Copy link

@vercel vercel bot commented on 1ee9cac Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.