Skip to content

Commit aea606b

Browse files
author
sw-yx
committed
memoize gotrueinstance creation
1 parent fb62167 commit aea606b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/index.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,14 @@ export function useNetlifyIdentity(
9898
url: string,
9999
onAuthChange: authChangeParam = () => {}
100100
): ReactNetlifyIdentityAPI {
101-
const goTrueInstance = new GoTrue({
102-
APIUrl: `${url}/.netlify/identity`,
103-
setCookie: true,
104-
});
101+
const goTrueInstance = React.useMemo(
102+
() =>
103+
new GoTrue({
104+
APIUrl: `${url}/.netlify/identity`,
105+
setCookie: true,
106+
}),
107+
[url]
108+
);
105109

106110
const [user, setUser] = React.useState<User | undefined>(
107111
goTrueInstance.currentUser() || undefined

0 commit comments

Comments
 (0)