Description
Hello, I forked the repo and I was playing around a little. I've noticed this thing, where if we pass a memoized function to the widget, which is used in the dependency array of the component, and we update some state (count in my example), this function depends on, and then we try to verify via the Altcha widget, it fires the "verified" event state twice (+calls the function twice, first with the initial state value, then the newest state value). I guess the reason for this behaviour is that the initial listener is not removed (?) and then the listener fires for both the initial listener and the newest listener.
Is the reason for this just me not understanding how to properly remove the event listener?
How to replicate:
- clone the forked repo
- update the state via the increment button (might take a couple of clicks)
- click to validate altcha
- observe the console - it should log the "verified" event twice -> calling the memoized function twice
I added a regular document click listener to see if it would actually get removed properly - seems that it does - since it actually only logs once (??).
Could anyone help me get this to work? This is just a simplified example of what my app should be doing (call a memoized function once it gets verified)