diff --git a/packages/app-staking/src/index.tsx b/packages/app-staking/src/index.tsx index 7b38851fcc74..5f2c2b7e380a 100644 --- a/packages/app-staking/src/index.tsx +++ b/packages/app-staking/src/index.tsx @@ -9,7 +9,7 @@ import { ComponentProps } from './types'; import React from 'react'; import { Route, Switch } from 'react-router'; -import { useRouteMatch } from 'react-router-dom'; +import { useLocation } from 'react-router-dom'; import styled from 'styled-components'; import { Option } from '@polkadot/types'; import { HelpOverlay } from '@polkadot/react-components'; @@ -43,12 +43,12 @@ function transformStakingControllers ([stashes, controllers]: [AccountId[], Opti function App ({ basePath, className, t }: Props): React.ReactElement { const { api } = useApi(); const { allAccounts, hasAccounts } = useAccounts(); + const { pathname } = useLocation(); const stakingControllers = trackStream<[string[], string[]]>(api.derive.staking.controllers, [], { transform: transformStakingControllers }); const bestNumber = trackStream(api.derive.chain.bestNumber, []); const recentlyOnline = trackStream(api.derive.imOnline.receivedHeartbeats, []); const stakingOverview = trackStream(api.derive.staking.overview, []); const sessionRewards = useSessionRewards(MAX_SESSIONS); - const routeMatch = useRouteMatch({ path: basePath, strict: true }); const hasQueries = hasAccounts && !!(api.query.imOnline?.authoredBlocks); const [allStashes, allControllers] = stakingControllers || EMPTY_ALL; @@ -103,12 +103,12 @@ function App ({ basePath, className, t }: Props): React.ReactElement { /> - {_renderComponent(Actions)} {_renderComponent(Query)} {_renderComponent(Query)} {_renderComponent(Targets)} - {_renderComponent(Overview, routeMatch?.isExact ? '' : 'staking--hidden')} + {_renderComponent(Actions, pathname === `${basePath}/actions` ? '' : 'staking--hidden')} + {_renderComponent(Overview, pathname === basePath ? '' : 'staking--hidden')} ); }