mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-25 16:36:34 -05:00
fix: make sure fetch function doesn't get called repeatedly on onMount (#4669)
This commit is contained in:
@@ -118,13 +118,16 @@ export const useAuthQuery = <T>(
|
||||
fn();
|
||||
} else {
|
||||
onMount(value, () => {
|
||||
setTimeout(() => {
|
||||
fn();
|
||||
const timeoutId = setTimeout(() => {
|
||||
if (!isMounted) {
|
||||
fn();
|
||||
isMounted = true;
|
||||
}
|
||||
}, 0);
|
||||
isMounted = true;
|
||||
return () => {
|
||||
value.off();
|
||||
initAtom.off();
|
||||
clearTimeout(timeoutId);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user