-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger from anywhere? #32
Comments
Triggering from a hook sounds like a must-have feature! |
Hey guys! I've rebuilt the library and I'll publish it in the upcoming days. Here's the new way of handling rewards in v2.0.0 - I hope it suits your needs better this time! import { useReward } from 'react-rewards';
...
const { reward, isAnimating } = useReward('rewardId', 'confetti');
...
<button
disabled={isAnimating}
onClick={reward}
>
<span id="rewardId" />
🎉
</button> Basically, you'll want to have an element with a matching ID anywhere in the DOM and then you can call the function that useReward hook provides. This way you can shoot the confettis from anywhere, I guess! :) |
what to add in RewardID??? |
Is it possible to trigger rewards from within a hook, similar to how react-toastify works? (https://www.npmjs.com/package/react-toastify)
The text was updated successfully, but these errors were encountered: