Skip to content

Commit

Permalink
chore(clerk-react): Use errorThrower utility to throw error in withPa…
Browse files Browse the repository at this point in the history
…thDefaultRouting
  • Loading branch information
octoper committed Dec 8, 2023
1 parent 479ee7e commit 5a855b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/react/src/components/withPathBasedRouting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import type { RoutingOptions } from '@clerk/types';
import type { ComponentProps, ComponentType } from 'react';
import React from 'react';

import { errorThrower } from '../utils/errorThrower';

export function withPathDefaultRouting<T, P extends RoutingOptions>(Component: T): T {
const BaseComponent = Component as ComponentType<RoutingOptions>;
const HOC = (props: ComponentProps<ComponentType<P>>) => {
if (!props.path && !props.routing) {
throw new Error('Clerk: You must specify path and routing props');
errorThrower.throw('You must specify path and routing props');
}

if (props.path) {
Expand All @@ -24,7 +26,6 @@ export function withPathDefaultRouting<T, P extends RoutingOptions>(Component: T
HOC.displayName = BaseComponent.displayName;

return Object.assign(HOC, {
displayName: BaseComponent.displayName,
...BaseComponent,
}) as unknown as T;
}) as T;
}

0 comments on commit 5a855b7

Please sign in to comment.