thedevelobear/react-rewards

Is it possible to launch an effect on page load..?

AndrewNow opened this issue · 1 comments

Hi all, I'm trying to run confetti on page load after a user pays for a product successfully. As such, I need to run the reward as soon as the payment confirmation page loads.

I wasn't able to get this to work with useEffect. Is this only possible via an onClick event?

Hey @AndrewNow! It should work with useEffect without any problems. Please see this CodeSandbox example and let me know if it helps. If not, please create your own CodeSandbox showing a bug or provide the steps to reproduce the issue :)

https://codesandbox.io/s/gracious-river-9of8bf?file=/src/App.js