Skip to content

Commit 1f5f6b1

Browse files
committed
fix(_setUser): export custom setter instead of useState to support manual onAuthChange
1 parent da99a22 commit 1f5f6b1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/index.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import React, {
44
useEffect,
55
createContext,
66
useContext,
7+
useCallback,
78
// types
8-
Dispatch,
9-
SetStateAction,
109
ReactNode,
11-
useCallback,
1210
} from 'react';
1311

1412
import GoTrue, {
@@ -48,7 +46,7 @@ type MaybeUserPromise = Promise<User | undefined>;
4846
export type ReactNetlifyIdentityAPI = {
4947
user: User | undefined;
5048
/** not meant for normal use! you should mostly use one of the other exported methods to update the user instance */
51-
setUser: Dispatch<SetStateAction<User | undefined>>;
49+
setUser: (_user: GoTrueUser | undefined) => GoTrueUser | undefined;
5250
isConfirmedUser: boolean;
5351
isLoggedIn: boolean;
5452
signupUser: (
@@ -294,7 +292,7 @@ export function useNetlifyIdentity(
294292
return {
295293
user,
296294
/** not meant for normal use! you should mostly use one of the other exported methods to update the user instance */
297-
setUser,
295+
setUser: _setUser,
298296
isConfirmedUser: !!(user && user.confirmed_at),
299297
isLoggedIn: !!user,
300298
signupUser,

0 commit comments

Comments
 (0)