Have a tabs component which work perfectly with the router.query state
useEffect(() => {
let found = false;
if (currentTab !== 'leads') {
router.push(`${id}?tab=${currentTab}`, undefined, {
shallow: true,
});
}
}, [currentTab]);
useEffect(() => {
if (router.query.tab !== currentTab) {
setCurrentTab(router.query.tab);
}
}, [router.query.tab]);
The problem arises when the rendered tab component push its own query state.
useEffect(() => {
router.push(`?${queryString.stringify({tab:"y")}`, undefined, {
shallow: true,
});
}, [state]);
the below useEffect router.push tab doesnt affect the second useEffect. so if i move tab from x to y. the url bar tab stucks to x but the component works fine.