Fix useMatch not working with optional path segment

This commit is contained in:
Lim Chee Aun 2023-02-06 19:29:00 +08:00
parent 3aea09fd42
commit 692851b24c

View file

@ -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);