Skip to content

Commit d4a99be

Browse files
committed
chore(clerk-react,nextjs): Improve comments
1 parent 29bb257 commit d4a99be

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/nextjs/src/app-router/server/controlComponents.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,24 @@ export function SignedOut(props: React.PropsWithChildren) {
1818
type ProtectServerComponentProps = React.ComponentProps<typeof ProtectClientComponent>;
1919

2020
/**
21-
* Use `<Protect/>` in order to prevent unauthenticated or unauthorized user from accessing the children passed to the component.
21+
* Use `<Protect/>` in order to prevent unauthenticated or unauthorized users from accessing the children passed to the component.
2222
*
2323
* Examples:
2424
* ```
2525
* <Protect permission="a_permission_key" />
2626
* <Protect role="a_role_key" />
2727
* <Protect condition={(has) => has({permission:"a_permission_key"})} />
2828
* <Protect condition={(has) => has({role:"a_role_key"})} />
29-
* <Protect fallback={<p>Unauthorized</p>}/>
29+
* <Protect fallback={<p>Unauthorized</p>} />
3030
* ```
3131
*/
3232
export function Protect(props: ProtectServerComponentProps) {
3333
const { children, fallback, ...restAuthorizedParams } = props;
3434
const { has, userId } = auth();
3535

3636
/**
37-
* If neither of the authorization params are passed behave as the `<SignedIn/>`
37+
* If neither of the authorization params are passed behave as the `<SignedIn/>`.
38+
* If fallback is present render that instead of rendering nothing.
3839
*/
3940
if (!restAuthorizedParams.condition && !restAuthorizedParams.role && !restAuthorizedParams.permission) {
4041
if (userId) {
@@ -58,7 +59,7 @@ export function Protect(props: ProtectServerComponentProps) {
5859
}
5960

6061
/**
61-
* Fallback to custom ui or null if authorization checks failed
62+
* Fallback to UI provided by user or `null` if authorization checks failed
6263
*/
6364
return <>{fallback ?? null}</>;
6465
}

packages/react/src/components/controlComponents.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,23 @@ type ProtectProps = React.PropsWithChildren<
7474
>;
7575

7676
/**
77-
* Use `<Protect/>` in order to prevent unauthenticated or unauthorized user from accessing the children passed to the component.
77+
* Use `<Protect/>` in order to prevent unauthenticated or unauthorized users from accessing the children passed to the component.
7878
*
7979
* Examples:
8080
* ```
8181
* <Protect permission="a_permission_key" />
8282
* <Protect role="a_role_key" />
8383
* <Protect condition={(has) => has({permission:"a_permission_key"})} />
8484
* <Protect condition={(has) => has({role:"a_role_key"})} />
85-
* <Protect fallback={<p>Unauthorized</p>}/>
85+
* <Protect fallback={<p>Unauthorized</p>} />
8686
* ```
8787
*/
8888
export const Protect = ({ children, fallback, ...restAuthorizedParams }: ProtectProps) => {
8989
const { has, userId } = useAuth();
9090

9191
/**
92-
* If neither of the authorization params are passed behave as the `<SignedIn/>`
92+
* If neither of the authorization params are passed behave as the `<SignedIn/>`.
93+
* If fallback is present render that instead of rendering nothing.
9394
*/
9495
if (!restAuthorizedParams.condition && !restAuthorizedParams.role && !restAuthorizedParams.permission) {
9596
if (userId) {
@@ -113,7 +114,7 @@ export const Protect = ({ children, fallback, ...restAuthorizedParams }: Protect
113114
}
114115

115116
/**
116-
* Fallback to custom ui or null if authorization checks failed
117+
* Fallback to UI provided by user or `null` if authorization checks failed
117118
*/
118119
return <>{fallback ?? null}</>;
119120
};

0 commit comments

Comments
 (0)