I am wondering if it’s safe to use history.listen
inside a useEffect
on an IonPage
.
ex.
useEffect(() => {
return history.listen((location): void => {
if (location.pathname === '/hello') {
// do stuff
}
});
}, []);
My concern is that the returned function from listen()
not being called and unregistering the listener. IonPage
's (from my experience) don’t always unmount as expected and the above create multiple listeners every time this page was loaded/rendered.
1 post - 1 participant