removed uniqueness in hook namespace
This commit is contained in:
parent
e6f7647a51
commit
1505cd6251
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue