Vercel/src/photo/PhotoEscapeHandler.tsx
2025-02-17 17:54:00 -06:00

23 lines
571 B
TypeScript

'use client';
import { getEscapePath } from '@/app/paths';
import { useRouter, usePathname } from 'next/navigation';
import { useCallback } from 'react';
import useEscapeHandler from '../utility/useEscapeHandler';
export default function PhotoEscapeHandler() {
const router = useRouter();
const pathname = usePathname();
const escapePath = getEscapePath(pathname);
const escapeHandler = useCallback(() => {
if (escapePath) { router.push(escapePath, { scroll: false }); }
}, [escapePath, router]);
useEscapeHandler(escapeHandler);
return null;
}