From 1505cd6251388ce391bcd7ea4b0055349912000a Mon Sep 17 00:00:00 2001 From: rjchow Date: Fri, 6 Sep 2024 14:31:32 +1000 Subject: [PATCH] removed uniqueness in hook namespace --- plugins/woocommerce-admin/client/settings/routes.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/woocommerce-admin/client/settings/routes.js b/plugins/woocommerce-admin/client/settings/routes.js index 89a83d8cf75..4daed1eb79e 100644 --- a/plugins/woocommerce-admin/client/settings/routes.js +++ b/plugins/woocommerce-admin/client/settings/routes.js @@ -31,7 +31,7 @@ export const useGetRoute = ( section ) => { : sections[ section || '' ]; useEffect( () => { - const uniqueNamespaceIdentifier = `woocommerce_${ new Date().getTime() }`; // unique key for namespace + const namespaceIdentifier = `woocommerce_settings_hook_${ page }_${ section }`; // unique key for namespace const newPage = { page: 'my-example', areas: { @@ -45,18 +45,18 @@ export const useGetRoute = ( section ) => { }; addFilter( 'woocommerce_admin_settings_pages', - uniqueNamespaceIdentifier, + namespaceIdentifier, ( pages ) => { - console.log( 'adding filter as it was not found', pages ); + console.log( 'adding filter to', pages ); return [ ...pages, newPage ]; } ); return () => removeFilter( 'woocommerce_admin_settings_pages', - uniqueNamespaceIdentifier + namespaceIdentifier ); - }, [ section ] ); + }, [ page, section ] ); if ( ! Object.keys( settingsData ).includes( page ) ) { return {