1- import React , { useState , useEffect , useCallback } from 'react'
1+ import React , { useCallback , useEffect , useState } from 'react'
22import { faListUl , faProjectDiagram } from '@fortawesome/free-solid-svg-icons'
3- import { useHistory } from 'react-router-dom'
43
5- import { useQuery } from 'hooks/useQuery'
4+ import { useQuery , useUpdateQueryString } from 'hooks/useQuery'
65import { BlockchainNetwork , TransactionsTableContext } from './context/TransactionsTableContext'
76import { useGetTxOrders , useTxOrderExplorerLink } from 'hooks/useGetOrders'
87import RedirectToSearch from 'components/RedirectToSearch'
98import { RedirectToNetwork , useNetworkId } from 'state/network'
109import { Order } from 'api/operator'
1110import { TransactionsTableWithData } from 'apps/explorer/components/TransactionsTableWidget/TransactionsTableWithData'
12- import { TabItemInterface , TabIcon } from 'components/common/Tabs/Tabs'
11+ import { TabIcon , TabItemInterface } from 'components/common/Tabs/Tabs'
1312import ExplorerTabs from '../common/ExplorerTabs/ExplorerTabs'
14- import { TitleAddress , FlexContainer , Title } from 'apps/explorer/pages/styled'
13+ import { FlexContainer , Title , TitleAddress } from 'apps/explorer/pages/styled'
1514import { BlockExplorerLink } from 'components/common/BlockExplorerLink'
1615import { ConnectionStatus } from 'components/ConnectionStatus'
1716import { Notification } from 'components/Notification'
1817import { TransactionBatchGraph } from 'apps/explorer/components/TransanctionBatchGraph'
1918import CowLoading from 'components/common/CowLoading'
19+ import { TAB_QUERY_PARAM_KEY } from 'apps/explorer/const'
2020
2121interface Props {
2222 txHash : string
@@ -33,7 +33,7 @@ const DEFAULT_TAB = TabView[1]
3333
3434function useQueryViewParams ( ) : { tab : string } {
3535 const query = useQuery ( )
36- return { tab : query . get ( 'tab' ) ?. toUpperCase ( ) || DEFAULT_TAB } // if URL param empty will be used DEFAULT
36+ return { tab : query . get ( TAB_QUERY_PARAM_KEY ) ?. toUpperCase ( ) || DEFAULT_TAB } // if URL param empty will be used DEFAULT
3737}
3838
3939const tabItems = ( orders : Order [ ] | undefined , networkId : BlockchainNetwork , txHash : string ) : TabItemInterface [ ] => {
@@ -61,7 +61,7 @@ export const TransactionsTableWidget: React.FC<Props> = ({ txHash }) => {
6161 const isZeroOrders = ! ! ( orders && orders . length === 0 )
6262 const notGpv2ExplorerData = useTxOrderExplorerLink ( txHash , isZeroOrders )
6363
64- const history = useHistory ( )
64+ const updateQueryString = useUpdateQueryString ( )
6565
6666 // Avoid redirecting until another network is searched again
6767 useEffect ( ( ) => {
@@ -81,9 +81,10 @@ export const TransactionsTableWidget: React.FC<Props> = ({ txHash }) => {
8181 setTabViewSelected ( TabView [ newTabViewName ] )
8282 } , [ ] )
8383
84- useEffect ( ( ) => {
85- history . replace ( { search : `?tab=${ TabView [ tabViewSelected ] . toLowerCase ( ) } ` } )
86- } , [ history , tabViewSelected ] )
84+ useEffect (
85+ ( ) => updateQueryString ( TAB_QUERY_PARAM_KEY , TabView [ tabViewSelected ] . toLowerCase ( ) ) ,
86+ [ tabViewSelected , updateQueryString ] ,
87+ )
8788
8889 if ( errorTxPresentInNetworkId && networkId != errorTxPresentInNetworkId ) {
8990 return < RedirectToNetwork networkId = { errorTxPresentInNetworkId } />
0 commit comments