Add workloads/ecommerce/src/components/navigation/CategoryMenu.tsx
Build and Push Frontend / build (push) Successful in 5m20s
Build and Push Frontend / build (push) Successful in 5m20s
This commit is contained in:
@@ -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 <div key={navigationKey}>{children}</div>;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user