Skip to content

juanoa/reactioning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c01b212 · Jan 29, 2025

History

35 Commits
Jan 25, 2025
Jan 25, 2025
Jan 29, 2025
Jan 29, 2025
Jan 24, 2025
Jan 26, 2025
Jan 29, 2025
Jan 24, 2025
Jan 24, 2025
Jan 29, 2025
Jan 29, 2025
Jan 24, 2025
Jan 24, 2025
Jan 24, 2025
Jan 24, 2025
Jan 24, 2025

Repository files navigation

Reactioning

Just a simple library to show beautiful reactions in your app.

npm version Package size npm monthly downloads License

Demo

npm i -E reactioning

Reactions available

  • thumbUp 👍
  • hearth ❤️
  • thumbDown 👎
  • rocket 🚀

I have more reactions in roadmap! (also custom reactions)

Example

export const App = () => {
  const [reactions, setReactions] = useState<Reactions>({
    hearth: { count: 11 },
    thumbUp: { count: 0 },
    rocket: { count: 12 },
  });

  const handleClick = (
    e: React.MouseEvent<HTMLDivElement>,
    reaction: "thumbUp" | "hearth" | "thumbDown" | "rocket"
  ) => {
    setReactions((prev) => {
      const currentReaction = prev[reaction];
      if (!currentReaction) return prev;

      return {
        ...prev,
        [reaction]: {
          ...currentReaction,
          count: currentReaction.selected
            ? currentReaction.count - 1
            : currentReaction.count + 1,
          selected: !currentReaction.selected,
        },
      };
    });
  };

  return <ReactionsContainer values={reactions} onClick={handleClick} />;
};