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
// Setup the event listeneruseEffect(()=>{console.log("Mounting GaEventsListener");// Set up the event listener with EventsOnconstcancelGaEventListener=EventsOn("GaEventsListen",handleGaEventsListen,);// Cleanup function to remove the event listener on unmountreturn()=>{console.log("Unmounting GaEventsListener");if(typeofcancelGaEventListener==="function"){cancelGaEventListener();// Cancel the listener using the function returned by EventsOn}};},[]);// No dependencies to avoid infinite loop
normally works fine. but if I navigate back(either with context menu or useNavigate hook) error occur. which i believe wails internal "event.js" error as it fails to kill the event listener.
Then if i refresh and re-enter into the page then i have two event listener as my callback func triggers twice.
I event tried to use "EventsOff" explicitly before setting a "EventsOn" but that goes to vain.
Am I implementing the navigation right with hash router and useNavigate?
my router setup:
importReactfrom"react";importReactDOMfrom"react-dom/client";import{RouterProvider,createHashRouter}from"react-router-dom";import"./index.css";importDashboardfrom"./pages/Dashboard";importPlaygroundfrom"./pages/Playground/Playground";importLoginfrom"./pages/Login/Login";import{usePaymentSync}from"./hooks/usePaymentSync";import{useAuthSync}from"./hooks/useAuthSync";// Define the routes using createHashRouterconstrouter=createHashRouter([{path: "/",element: <Dashboard/>,},{path: "/playground",element: <Playground/>,},{path: "/login",element: <Login/>,},]);constApp=()=>{useAuthSync();// Sync auth state on app startusePaymentSync();// Sync payment state on app startreturn<RouterProviderrouter={router}/>;};ReactDOM.createRoot(document.getElementById("root")).render(<React.StrictMode><App/></React.StrictMode>,);
To Reproduce
navigate to the route
setup event listener with useEffect with no dependency
navigate back to new route
See console log for error
navigate back to event page
now the callback function inside the EventsOn would run twice
Expected behaviour
event listener should be termination when useEffect cancel function run. Or if I explicitly call EventsOff before calling EventsOn the previous events should not exist.
Screenshots
No response
Attempted Fixes
No response
System Details
# Wails
Version | v2.9.1
# System
┌──────────────────────────────────────────────────────────────────────────────────────────────┐
| OS | Windows 10 Pro
|| Version | 2009 (Build: 22631)
|| ID | 23H2
|| Go Version | go1.23.0
|| Platform | windows
|| Architecture | amd64
|| CPU | AMD Ryzen 5 5600G with Radeon Graphics || GPU | AMD Radeon(TM) Graphics (Advanced Micro Devices, Inc.) - Driver: 31.0.14046.0 || Memory | 24GB
|
└──────────────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌───────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version || WebView2 | N/A | Installed | 129.0.2792.65 || Nodejs | N/A | Installed | 22.4.0 || npm | N/A | Installed | 10.2.5 ||*upx | N/A | Available |||*nsis | N/A | Available ||
└─────────────── * - Optional Dependency ───────────────┘
Additional context
No response
The text was updated successfully, but these errors were encountered:
Description
Having issue cleaning listener.
normally works fine. but if I navigate back(either with context menu or useNavigate hook) error occur. which i believe wails internal "event.js" error as it fails to kill the event listener.
Then if i refresh and re-enter into the page then i have two event listener as my callback func triggers twice.
I event tried to use "EventsOff" explicitly before setting a "EventsOn" but that goes to vain.
Am I implementing the navigation right with hash router and useNavigate?
my router setup:
To Reproduce
Expected behaviour
event listener should be termination when useEffect cancel function run. Or if I explicitly call EventsOff before calling EventsOn the previous events should not exist.
Screenshots
No response
Attempted Fixes
No response
System Details
Additional context
No response
The text was updated successfully, but these errors were encountered: