diff --git a/packages/page-staking/src/Actions/Account/index.tsx b/packages/page-staking/src/Actions/Account/index.tsx index 6653bb1db5..67dc799b40 100644 --- a/packages/page-staking/src/Actions/Account/index.tsx +++ b/packages/page-staking/src/Actions/Account/index.tsx @@ -99,8 +99,8 @@ function Account ({ allStashes, className, isOwnStash, isVisible, next, onUpdate const { allAccounts } = useAccounts(); const validateInfo = useCall(api.query.staking.validators, [stashId]); const balancesAll = useCall(api.derive.balances.all as any, [stashId]); - const stakingAccount = isVisible ? useCall(api.derive.staking.account as any, [stashId]) : undefined; - const stakingRewardsAll = isVisible ? useCall(api.derive.staking.stakerRewards as any, [stashId]) : undefined; + const stakingAccount = useCall(isVisible && api.derive.staking.account as any, [stashId]); + const stakingRewardsAll = useCall(isVisible && api.derive.staking.stakerRewards as any, [stashId]); const [[stakingRewards, payoutEras], setStakingRewards] = useState<[DeriveStakerReward[], EraIndex[]]>([[], []]); const [{ controllerId, destination, hexSessionIdQueue, hexSessionIdNext, isLoading, isOwnController, isStashNominating, isStashValidating, nominees, sessionIds, validatorPrefs }, setStakeState] = useState({ controllerId: null, destination: 0, hexSessionIdNext: null, hexSessionIdQueue: null, isLoading: true, isOwnController: false, isStashNominating: false, isStashValidating: false, sessionIds: [] }); const [activeNoms, setActiveNoms] = useState([]); diff --git a/packages/page-staking/src/Overview/Address.tsx b/packages/page-staking/src/Overview/Address.tsx index 56a653f116..7d2a960459 100644 --- a/packages/page-staking/src/Overview/Address.tsx +++ b/packages/page-staking/src/Overview/Address.tsx @@ -102,7 +102,7 @@ export default function Address ({ address, className, filterName, hasQueries, h const { t } = useTranslation(); const { api } = useApi(); const info = useCall(api.derive.accounts.info as any, [address]); - const stakingInfo = isMain ? useCall(api.derive.staking.query as any, [address]) : undefined; + const stakingInfo = useCall(isMain && api.derive.staking.query as any, [address]); const [{ commission, nominators, stakeOwn, stakeOther }, setStakingState] = useState({ nominators: [] }); const [isExpanded, setIsExpanded] = useState(false); const [isVisible, setIsVisible] = useState(true); diff --git a/packages/react-hooks/src/useCall.tsx b/packages/react-hooks/src/useCall.tsx index 11bb44c212..3f605b67ab 100644 --- a/packages/react-hooks/src/useCall.tsx +++ b/packages/react-hooks/src/useCall.tsx @@ -98,7 +98,7 @@ function subscribe (mounted: MountedRef, tracker: TrackerRef, fn: TrackFn | // - returns a promise with an unsubscribe function // - has a callback to set the value // FIXME The typings here need some serious TLC -export default function useCall (fn: TrackFn | undefined | null, params: CallParams = [], options: CallOptions = {}): T | undefined { +export default function useCall (fn: TrackFn | undefined | null | false, params: CallParams = [], options: CallOptions = {}): T | undefined { const mounted = useIsMountedRef(); const tracker = useRef({ isActive: false, count: 0, serialized: null, subscriber: null }); const [value, setValue] = useState(options.defaultValue);