Skip to content

Commit

Permalink
[ui] fix Link not accepting empty strings for to (#7724)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 237726780dae9c5de9f0c66316a4fce11567844b
  • Loading branch information
bsiaotickchong authored and Lightspark Eng committed Nov 27, 2023
1 parent 7fe5467 commit 317c579
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/ui/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
type NavigateOptions,
} from "react-router-dom";
import { colors } from "./styles/colors.js";
import { isString } from "./utils/strings.js";
/* eslint-enable no-restricted-imports */

export type QueryParams =
Expand Down Expand Up @@ -88,12 +89,12 @@ export function Link<RoutesType extends string>({
blue = false,
newTab = false,
}: LinkProps<RoutesType>) {
if (!to && !externalLink) {
if (!isString(to) && !externalLink) {
throw new Error("Link must have either `to` or `externalLink` defined");
}

let toStr: RoutesType | string;
if (to) {
if (isString(to)) {
toStr = replaceParams(to, params);
toStr += hash ? `#${hash}` : "";
} else {
Expand Down

0 comments on commit 317c579

Please sign in to comment.