Skip to content

Commit

Permalink
ensure 'to' to be string on destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dswbx authored and molefrog committed Aug 28, 2024
1 parent 4162953 commit 3466ef0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/wouter/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const Link = forwardRef((props, ref) => {
const [currentPath, navigate] = useLocationFromRouter(router);

const {
to,
to = "",
href: targetPath = to,
onClick: _onClick,
asChild,
Expand Down Expand Up @@ -265,9 +265,7 @@ export const Link = forwardRef((props, ref) => {

// handle nested routers and absolute paths
const href = router.hrefs(
(targetPath ?? "")[0] === "~"
? targetPath.slice(1)
: router.base + targetPath,
targetPath[0] === "~" ? targetPath.slice(1) : router.base + targetPath,
router // pass router as a second argument for convinience
);

Expand Down

0 comments on commit 3466ef0

Please sign in to comment.