Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(clerk-react): Mark setSession as deprecated #1486

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-tomatoes-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-react': patch
---

Mark setSession as deprecated when it is re-exported within hooks
29 changes: 26 additions & 3 deletions packages/react/src/hooks/useSessionList.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
import type { SetActive, SessionResource, SetSession } from '@clerk/types';
import type { SessionResource, SetActive, SetSession } from '@clerk/types';

import { useClientContext } from '../contexts/ClientContext';
import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext';

type UseSessionListReturn =
| { isLoaded: false; sessions: undefined; setSession: undefined; setActive: undefined }
| { isLoaded: true; sessions: SessionResource[]; setSession: SetSession; setActive: SetActive };
| {
isLoaded: false;
sessions: undefined;
/**
* @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead
* Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user.
* @param session Passed session resource object, session id (string version) or null
* @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions.
*/
setSession: undefined;
setActive: undefined;
}
| {
isLoaded: true;
sessions: SessionResource[];

/**
* @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead
* Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user.
* @param session Passed session resource object, session id (string version) or null
* @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions.
*/
setSession: SetSession;
setActive: SetActive;
};

type UseSessionList = () => UseSessionListReturn;

Expand Down
26 changes: 24 additions & 2 deletions packages/react/src/hooks/useSignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,30 @@ import { useClientContext } from '../contexts/ClientContext';
import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext';

type UseSignInReturn =
| { isLoaded: false; signIn: undefined; setSession: undefined; setActive: undefined }
| { isLoaded: true; signIn: SignInResource; setSession: SetSession; setActive: SetActive };
| {
isLoaded: false;
signIn: undefined;
/**
* @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead
* Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user.
* @param session Passed session resource object, session id (string version) or null
* @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions.
*/
setSession: undefined;
setActive: undefined;
}
| {
isLoaded: true;
signIn: SignInResource;
/**
* @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead
* Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user.
* @param session Passed session resource object, session id (string version) or null
* @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions.
*/
setSession: SetSession;
setActive: SetActive;
};

type UseSignIn = () => UseSignInReturn;

Expand Down
26 changes: 24 additions & 2 deletions packages/react/src/hooks/useSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,30 @@ import { useClientContext } from '../contexts/ClientContext';
import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext';

type UseSignUpReturn =
| { isLoaded: false; signUp: undefined; setSession: undefined; setActive: undefined }
| { isLoaded: true; signUp: SignUpResource; setSession: SetSession; setActive: SetActive };
| {
isLoaded: false;
signUp: undefined;
/**
* @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead
* Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user.
* @param session Passed session resource object, session id (string version) or null
* @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions.
*/
setSession: undefined;
setActive: undefined;
}
| {
isLoaded: true;
signUp: SignUpResource;
/**
* @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead
* Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user.
* @param session Passed session resource object, session id (string version) or null
* @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions.
*/
setSession: SetSession;
setActive: SetActive;
};

type UseSignUp = () => UseSignUpReturn;

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export interface Clerk {

/**
* @deprecated This method is deprecated and will be removed in the future. Use {@link Clerk.setActive} instead
* Set the current session explicitly. Setting the session to `null` deletes the active session.
* Set the current session explicitly. Setting the session to `null` unsets the active session and signs out the user.
* @param session Passed session resource object, session id (string version) or null
* @param beforeEmit Callback run just before the active session is set to the passed object. Can be used to hook up for pre-navigation actions.
*/
Expand Down