From aea7348b056053e1412baa1f9db94ad5c360148e Mon Sep 17 00:00:00 2001 From: Dylan Staley <88163+dstaley@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:42:39 -0800 Subject: [PATCH] fix(clerk-react): Infer React.JSX.Element instead of explicit JSX.Element --- .changeset/lemon-planes-dress.md | 5 +++++ packages/react/src/components/controlComponents.tsx | 10 +++++----- packages/react/src/contexts/ClerkContextProvider.tsx | 2 +- packages/react/src/contexts/ClerkProvider.tsx | 2 +- packages/react/src/utils/useCustomElementPortal.tsx | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .changeset/lemon-planes-dress.md diff --git a/.changeset/lemon-planes-dress.md b/.changeset/lemon-planes-dress.md new file mode 100644 index 00000000000..bf1bf9740e3 --- /dev/null +++ b/.changeset/lemon-planes-dress.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-react': patch +--- + +Return components as `React.JSX.Element` instead of `JSX.Element` diff --git a/packages/react/src/components/controlComponents.tsx b/packages/react/src/components/controlComponents.tsx index 0b54363fc38..4f41ef24862 100644 --- a/packages/react/src/components/controlComponents.tsx +++ b/packages/react/src/components/controlComponents.tsx @@ -15,7 +15,7 @@ import { useAssertWrappedByClerkProvider } from '../hooks/useAssertWrappedByCler import type { RedirectToSignInProps, RedirectToSignUpProps, WithClerkProp } from '../types'; import { withClerk } from './withClerk'; -export const SignedIn = ({ children }: React.PropsWithChildren): JSX.Element | null => { +export const SignedIn = ({ children }: React.PropsWithChildren) => { useAssertWrappedByClerkProvider('SignedIn'); const { userId } = useAuthContext(); @@ -25,7 +25,7 @@ export const SignedIn = ({ children }: React.PropsWithChildren): JSX.El return null; }; -export const SignedOut = ({ children }: React.PropsWithChildren): JSX.Element | null => { +export const SignedOut = ({ children }: React.PropsWithChildren) => { useAssertWrappedByClerkProvider('SignedOut'); const { userId } = useAuthContext(); @@ -35,7 +35,7 @@ export const SignedOut = ({ children }: React.PropsWithChildren): JSX.E return null; }; -export const ClerkLoaded = ({ children }: React.PropsWithChildren): JSX.Element | null => { +export const ClerkLoaded = ({ children }: React.PropsWithChildren) => { useAssertWrappedByClerkProvider('ClerkLoaded'); const isomorphicClerk = useIsomorphicClerkContext(); @@ -45,7 +45,7 @@ export const ClerkLoaded = ({ children }: React.PropsWithChildren): JSX return <>{children}; }; -export const ClerkLoading = ({ children }: React.PropsWithChildren): JSX.Element | null => { +export const ClerkLoading = ({ children }: React.PropsWithChildren) => { useAssertWrappedByClerkProvider('ClerkLoading'); const isomorphicClerk = useIsomorphicClerkContext(); @@ -212,7 +212,7 @@ export const AuthenticateWithRedirectCallback = withClerk( 'AuthenticateWithRedirectCallback', ); -export const MultisessionAppSupport = ({ children }: React.PropsWithChildren): JSX.Element => { +export const MultisessionAppSupport = ({ children }: React.PropsWithChildren) => { useAssertWrappedByClerkProvider('MultisessionAppSupport'); const session = useSessionContext(); diff --git a/packages/react/src/contexts/ClerkContextProvider.tsx b/packages/react/src/contexts/ClerkContextProvider.tsx index 00b2c153dff..188bc2b3a5e 100644 --- a/packages/react/src/contexts/ClerkContextProvider.tsx +++ b/packages/react/src/contexts/ClerkContextProvider.tsx @@ -16,7 +16,7 @@ type ClerkContextProvider = { export type ClerkContextProviderState = Resources; -export function ClerkContextProvider(props: ClerkContextProvider): JSX.Element | null { +export function ClerkContextProvider(props: ClerkContextProvider) { const { isomorphicClerkOptions, initialState, children } = props; const { isomorphicClerk: clerk, loaded: clerkLoaded } = useLoadedIsomorphicClerk(isomorphicClerkOptions); diff --git a/packages/react/src/contexts/ClerkProvider.tsx b/packages/react/src/contexts/ClerkProvider.tsx index cc730af2f3c..66b21ed8a35 100644 --- a/packages/react/src/contexts/ClerkProvider.tsx +++ b/packages/react/src/contexts/ClerkProvider.tsx @@ -7,7 +7,7 @@ import type { ClerkProviderProps } from '../types'; import { withMaxAllowedInstancesGuard } from '../utils'; import { ClerkContextProvider } from './ClerkContextProvider'; -function ClerkProviderBase(props: ClerkProviderProps): JSX.Element { +function ClerkProviderBase(props: ClerkProviderProps) { const { initialState, children, __internal_bypassMissingPublishableKey, ...restIsomorphicClerkOptions } = props; const { publishableKey = '', Clerk: userInitialisedClerk } = restIsomorphicClerkOptions; diff --git a/packages/react/src/utils/useCustomElementPortal.tsx b/packages/react/src/utils/useCustomElementPortal.tsx index ba2bec4c692..3bdc3ef35ca 100644 --- a/packages/react/src/utils/useCustomElementPortal.tsx +++ b/packages/react/src/utils/useCustomElementPortal.tsx @@ -7,7 +7,7 @@ export type UseCustomElementPortalParams = { }; export type UseCustomElementPortalReturn = { - portal: () => JSX.Element; + portal: () => React.JSX.Element; mount: (node: Element) => void; unmount: () => void; id: number;