Im using material ui tabs, and Im pushing the tabs to url. I want to push the tab but not refresh the page every-time I change the tab. Here is my code, and Im using shallow:true but the problem remains:
const tabs = [
{ label: 'Details', value: 'details' },
{ label: 'Purchases', value: 'purchases' },
{ label: 'Money Transfer', value: 'moneyTransfer' },
{label:'User Activity',value:'userActivity'},
{label:'User Logs',value:'userLogs'}
];
const {
query: { UsersId,tab },
} = router
const handleTabsChange = (event: ChangeEvent<{}>, value: string): void => {
router.push({
pathname: `/dashboard/twigUsers/${UsersId}`,query: { tab:value}},undefined,{ shallow: true });
};
<Tabs
indicatorColor="primary"
onChange={handleTabsChange}
scrollButtons="auto"
sx={{ mt: 3 }}
textColor="primary"
value={tab}
variant="scrollable"
>
{tabs.map((tab) => (
<Tab
key={tab.value}
label={tab.label}
value={tab.value}
/>
))}
</Tabs>
{tab === 'details' && (
<UsersDetailsContainer user={user} userId={UsersId}/>
)}
{tab === 'purchases' && <PurchasesListTable userDetailsId={userDetailsId}/>}
{tab === 'moneyTransfer' && <MoneyTransferListTable userDetailsIdMT={userDetailsIdMT} />}
{tab==='userActivity' &&<UserActivity/>}
{tab==='userLogs' &&<UserLogs user={user} userId={twigUsersId}/>}