thedevelobear/react-rewards

how to add custom emoji

bilalturkmen opened this issue ยท 2 comments

Hello,
thanks for the nice package.
how to add custom emoji? it might be helpful add an example to the document.

i tried like below. is this the right way?

import { useReward } from 'react-rewards';
...
const { reward: confettiReward, isAnimating } = useReward(
    "rewardId",
    "emoji",
    {
      emoji: ["โšก๏ธ", "๐Ÿ’ฅ", "โœจ", "๐Ÿ’ซ", "๐ŸŒธ", "๐ŸŒŸ"],
    }
  );
...
<button
    disabled={isConfettiAnimating}
    onClick={() => {
        confettiReward();
    }}
>
    <span id="confettiReward" />
    ๐ŸŽ‰
</button>

Here is an example that works for me ๐Ÿ’œ:

import { useReward } from "react-rewards";
. . . 
const { reward: confettiReward, isAnimating } = useReward(
    "rewardId",
    "emoji",
    {
      emoji: ["โšก๏ธ", "โœจ", "๐Ÿ’œ", "๐Ÿš€"],
    }
  );
. . . 
<button 
        disabled={isAnimating} 
        onClick={() => {
                 confettiReward();
         }}
>
         <span id="rewardId" />
            ๐Ÿ’œ
</button>

thank you Ana,
We can also use some settings in the readme file

example

 const { reward: confettiReward, isAnimating } = useReward("rewardId", "emoji", {
    emoji: ["โšก๏ธ", "๐Ÿ’ฅ", "โœจ", "๐Ÿ’ซ", "๐ŸŒธ", "๐ŸŒŸ", "๐ŸŒ‚"],
    elementSize: 15,
    elementCount: 60,
    lifetime: 100,
  });

very nice package ๐Ÿ˜Š