onClose event trigger 2 times.
See original GitHub issueonCloese event trigger 2 times Following the code, I am getting closed alert two times once before showing the message & another one after closing the message.
toast.success('Successfully registered!', {
onClose: () => alert('closed')
});
Issue Analytics
- State:
- Created a year ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Why is the onClick event triggered twice? - Stack Overflow
It is calling twice because button is inside a span and span has onclick="alert('Boem')" , hence when you trigger click on button then...
Read more >Help with JavaScript event triggered twice :( : r/FreeCodeCamp
When you close the modal, it doesn't get rid of the next and prev buttons, it just hides them, meaning those event listeners...
Read more >How To Handle DOM and Window Events with React
In this tutorial, you'll learn how to handle events in React. ... This will add the event listener every time you trigger the...
Read more >onunload Event - W3Schools
Note: The onunload event is also triggered when a user reloads the page (and the onload event). Browser Support. Event. onunload, Yes, Yes,...
Read more >.unload() | jQuery API Documentation
A function to execute each time the event is triggered. ... 2. 3. $( window ).unload(function() {. return "Handler for .unload() called.";. }); ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lfernandez55 I feel your pain. Having a piece of code not acting the same way in dev and prod is a nightmare.
It’s not that it’s not worth fixing. React does not provide any API so far to address this behavior. Having to fix a framework behavior in a library is not always easy, especially in this case where the library code doesn’t do too much. You would encounter the same issue in your App if you use
useEffect
for mount and unmount. In that case, it’s visible because it calls a callback.As a maintainer, this is super frustrating. I really hope that the react team provides an alternative to this in a near future. All I can do now is propose an alternative 😞. If there was an easy fix, I would implement it right away, rest assured.
From the react documentation:
I think is related with this https://github.com/reactwg/react-18/discussions/19 Try disable React.StrictMode, it’s not solution, but unit someone fix it…