From 692851b24cdeac7daa4c2e095e5be6faafdbc477 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun <cheeaun@gmail.com> Date: Mon, 6 Feb 2023 19:29:00 +0800 Subject: [PATCH] Fix useMatch not working with optional path segment --- src/components/media-modal.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/media-modal.jsx b/src/components/media-modal.jsx index 47d3b8eb..d8a72cb2 100644 --- a/src/components/media-modal.jsx +++ b/src/components/media-modal.jsx @@ -16,7 +16,10 @@ function MediaModal({ onClose = () => {}, }) { const carouselRef = useRef(null); - const isStatusLocation = useMatch('/s/:instance?/:id'); + // NOTE: Optional path segment doesn't work yet + // https://github.com/remix-run/react-router/issues/10039 + // const isStatusLocation = useMatch('/s/:instance?/:id'); + const isStatusLocation = useMatch('/s/:instance/:id') || useMatch('/s/:id'); const [currentIndex, setCurrentIndex] = useState(index); const carouselFocusItem = useRef(null);