From 3466ef004850fd06c32a544ca390de22fd882f2d Mon Sep 17 00:00:00 2001 From: dswbx Date: Wed, 28 Aug 2024 19:18:11 +0200 Subject: [PATCH] ensure 'to' to be string on destructor --- packages/wouter/src/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/wouter/src/index.js b/packages/wouter/src/index.js index fc13290..795abed 100644 --- a/packages/wouter/src/index.js +++ b/packages/wouter/src/index.js @@ -230,7 +230,7 @@ export const Link = forwardRef((props, ref) => { const [currentPath, navigate] = useLocationFromRouter(router); const { - to, + to = "", href: targetPath = to, onClick: _onClick, asChild, @@ -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 );