removed uniqueness in hook namespace

This commit is contained in:
rjchow 2024-09-06 14:31:32 +10:00
parent e6f7647a51
commit 1505cd6251
No known key found for this signature in database
1 changed files with 5 additions and 5 deletions

View File

@ -31,7 +31,7 @@ export const useGetRoute = ( section ) => {
: sections[ section || '' ]; : sections[ section || '' ];
useEffect( () => { useEffect( () => {
const uniqueNamespaceIdentifier = `woocommerce_${ new Date().getTime() }`; // unique key for namespace const namespaceIdentifier = `woocommerce_settings_hook_${ page }_${ section }`; // unique key for namespace
const newPage = { const newPage = {
page: 'my-example', page: 'my-example',
areas: { areas: {
@ -45,18 +45,18 @@ export const useGetRoute = ( section ) => {
}; };
addFilter( addFilter(
'woocommerce_admin_settings_pages', 'woocommerce_admin_settings_pages',
uniqueNamespaceIdentifier, namespaceIdentifier,
( pages ) => { ( pages ) => {
console.log( 'adding filter as it was not found', pages ); console.log( 'adding filter to', pages );
return [ ...pages, newPage ]; return [ ...pages, newPage ];
} }
); );
return () => return () =>
removeFilter( removeFilter(
'woocommerce_admin_settings_pages', 'woocommerce_admin_settings_pages',
uniqueNamespaceIdentifier namespaceIdentifier
); );
}, [ section ] ); }, [ page, section ] );
if ( ! Object.keys( settingsData ).includes( page ) ) { if ( ! Object.keys( settingsData ).includes( page ) ) {
return { return {