From b4f390f6bade54acc62fdeec41a9227ba483e256 Mon Sep 17 00:00:00 2001 From: devops Date: Sun, 26 Jul 2026 21:36:26 +0000 Subject: [PATCH] Add workloads/ecommerce/src/components/catalog/CatalogRouteBoundary.tsx --- .../catalog/CatalogRouteBoundary.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 workloads/ecommerce/src/components/catalog/CatalogRouteBoundary.tsx diff --git a/workloads/ecommerce/src/components/catalog/CatalogRouteBoundary.tsx b/workloads/ecommerce/src/components/catalog/CatalogRouteBoundary.tsx new file mode 100644 index 0000000..6b11af4 --- /dev/null +++ b/workloads/ecommerce/src/components/catalog/CatalogRouteBoundary.tsx @@ -0,0 +1,29 @@ +"use client"; + +import type { ReactNode } from "react"; +import { usePathname, useSearchParams } from "next/navigation"; + +type CatalogRouteBoundaryProps = { + children: ReactNode; +}; + +/** + * Fuerza el remontaje del árbol del catálogo cuando cambia: + * - pathname + * - category + * - collection + * - section + * - búsqueda, orden u otros parámetros + * + * Esto evita que useState/useMemo conserven filtros de una navegación anterior. + */ +export default function CatalogRouteBoundary({ + children, +}: CatalogRouteBoundaryProps) { + const pathname = usePathname(); + const searchParams = useSearchParams(); + + const navigationKey = `${pathname}?${searchParams.toString()}`; + + return
{children}
; +} \ No newline at end of file