Skip to content

Commit 3f2216d

Browse files
committed
Revert "fix: clean up listener callbacks"
This reverts commit e2afe2a.
1 parent 4505b19 commit 3f2216d

1 file changed

Lines changed: 11 additions & 28 deletions

File tree

frontend/elements/src/contexts/AppProvider.tsx

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -370,58 +370,41 @@ const AppProvider = ({
370370
}, [isReadyToInit, authComponentFlow, componentName, init]);
371371

372372
useEffect(() => {
373-
const cleanUserDeleted = hanko.onUserDeleted(() => {
373+
hanko.onUserDeleted(() => {
374374
dispatchEvent("onUserDeleted");
375375
});
376376

377-
const cleanSessionCreated = hanko.onSessionCreated((detail) => {
377+
hanko.onSessionCreated((detail) => {
378378
dispatchEvent("onSessionCreated", detail);
379379
});
380380

381-
const cleanSessionExpired = hanko.onSessionExpired(() => {
381+
hanko.onSessionExpired(() => {
382382
dispatchEvent("onSessionExpired");
383383
});
384384

385-
const cleanUserLoggedOut = hanko.onUserLoggedOut(() => {
385+
hanko.onUserLoggedOut(() => {
386386
dispatchEvent("onUserLoggedOut");
387387
});
388388

389-
const cleanBeforeStateChange = hanko.onBeforeStateChange((detail) => {
389+
hanko.onBeforeStateChange((detail) => {
390390
dispatchEvent("onBeforeStateChange", detail);
391391
});
392392

393-
const cleanAfterStateChange = hanko.onAfterStateChange((detail) => {
393+
hanko.onAfterStateChange((detail) => {
394394
dispatchEvent("onAfterStateChange", detail);
395395
});
396-
397-
return () => {
398-
cleanUserDeleted();
399-
cleanSessionCreated();
400-
cleanSessionExpired();
401-
cleanUserLoggedOut();
402-
cleanBeforeStateChange();
403-
cleanAfterStateChange();
404-
};
405396
}, [hanko]);
406397

407-
useEffect(() => {
398+
useMemo(() => {
408399
const cb = () => {
409400
init(componentName);
410401
};
411402
if (["auth", "login", "registration"].includes(componentName)) {
412-
const cleanUserLoggedOut = hanko.onUserLoggedOut(cb);
413-
const cleanSessionExpired = hanko.onSessionExpired(cb);
414-
const cleanUserDeleted = hanko.onUserDeleted(cb);
415-
return () => {
416-
cleanUserLoggedOut();
417-
cleanSessionExpired();
418-
cleanUserDeleted();
419-
};
403+
hanko.onUserLoggedOut(cb);
404+
hanko.onSessionExpired(cb);
405+
hanko.onUserDeleted(cb);
420406
} else if (componentName === "profile") {
421-
const cleanSessionCreated = hanko.onSessionCreated(cb);
422-
return () => {
423-
cleanSessionCreated();
424-
};
407+
hanko.onSessionCreated(cb);
425408
}
426409
}, [componentName, hanko, init]);
427410

0 commit comments

Comments
 (0)