You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hey guys, im using this package to work with an SVG that is interactive with mouse clicks and keyboard presses using event listeners in a script that is inside the svg. It works great but I have one problem, if I click and open the SVG for the first time, it work perfectly, but if I click away from the svg into a different page, it still acts like the svg is there (meaning mouse clicks and key presses are still listened to, even though they dont be anything, and it console.logs() and error). When i click on the svg a second time to open it, the page crashes, so im guessing the script inside the svg is still active? i can solve it by refreshing the page, i tried refreshing in the return function of a useEffect hook, but that results in an endless loop of refreshing. So, basically I need to completely remove the SVG element when I switch pages in my app. I believe it has to do with useRef and removeChild? but im not sure. any tips would be great!!
Thanks
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
hey guys, im using this package to work with an SVG that is interactive with mouse clicks and keyboard presses using event listeners in a script that is inside the svg. It works great but I have one problem, if I click and open the SVG for the first time, it work perfectly, but if I click away from the svg into a different page, it still acts like the svg is there (meaning mouse clicks and key presses are still listened to, even though they dont be anything, and it console.logs() and error). When i click on the svg a second time to open it, the page crashes, so im guessing the script inside the svg is still active? i can solve it by refreshing the page, i tried refreshing in the return function of a useEffect hook, but that results in an endless loop of refreshing. So, basically I need to completely remove the SVG element when I switch pages in my app. I believe it has to do with useRef and removeChild? but im not sure. any tips would be great!!
Thanks
Beta Was this translation helpful? Give feedback.
All reactions