Files
explore/lib/hooks/useNotifyOnNavigation.tsx
T
284ced387a Metasuites placeholders (#1637)
* placeholders for address and txs

* placeholder for explorer link

* move phalcon link

* change api endpoint for demo

* Fixing upstream header too large

* ready flags and navigation events

* add ENV

---------

Co-authored-by: Nick Zenchik <[email protected]>
2024-03-08 08:44:58 +04:00

25 lines
782 B
TypeScript

import { usePathname } from 'next/navigation';
import { useRouter } from 'next/router';
import React from 'react';
import config from 'configs/app';
import getQueryParamString from 'lib/router/getQueryParamString';
export default function useNotifyOnNavigation() {
const router = useRouter();
const pathname = usePathname();
const tab = getQueryParamString(router.query.tab);
React.useEffect(() => {
if (config.features.metasuites.isEnabled) {
window.postMessage({ source: 'APP_ROUTER', type: 'PATHNAME_CHANGED' }, window.location.origin);
}
}, [ pathname ]);
React.useEffect(() => {
if (config.features.metasuites.isEnabled) {
window.postMessage({ source: 'APP_ROUTER', type: 'TAB_CHANGED' }, window.location.origin);
}
}, [ tab ]);
}