react-achievements-zustand
Version:
This package allows users to transpose a React achievements engine over their React apps using Zustand for state management
16 lines (14 loc) • 587 B
text/typescript
import { useAchievementStore } from '../store/useAchievementStore';
import { useAchievementContext } from '../providers/AchievementProvider';
export const useAchievement = () => {
const { updateMetrics, unlockedAchievements, resetStorage } = useAchievementContext() || {};
const { metrics, config, notifications } = useAchievementStore();
return {
metrics,
unlockedAchievements: unlockedAchievements || [],
notifications,
config,
updateMetrics: updateMetrics || (() => {}),
resetStorage: resetStorage || (() => {}),
};
};