From df77410f37faa1cec31e055f0b79214d770c7154 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Thu, 27 Feb 2020 21:07:05 +0100 Subject: [PATCH] fix: Fixes TypeError: Cannot read property 'receivedHeartbeats' of undefined (#2305) We're converting our chain from PoA to PoS in this PR https://github.com/DataHighway-DHX/node/pull/52/commits/7c8c96939ab6a2b77dd3a2f4bef427e831dafbda But when I run the chain with those latest changes I got error `TypeError: Cannot read property 'receivedHeartbeats' of undefined` when I tried to go to the Staking app using polkadot.js.org/apps, as explained here https://matrix.to/#/!XOxcnpiHXHhAjJfRFP:matrix.parity.io/$0oidO-aZvsjMRdskB2nig6P_Y4CjH4Gc6TMrl4V7ZB8?via=matrix.parity.io&via=matrix.org&via=matrix.dapp.org.uk After cloning https://github.com/polkadot-js/apps and debugging the error, I found that this change resolved the error and the Staking App runs --- packages/app-staking/src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app-staking/src/index.tsx b/packages/app-staking/src/index.tsx index 2158cdbc24..01810b26ef 100644 --- a/packages/app-staking/src/index.tsx +++ b/packages/app-staking/src/index.tsx @@ -39,7 +39,7 @@ function StakingApp ({ basePath, className }: Props): React.ReactElement transform: ([stashes]: [AccountId[]]): string[] => stashes.map((accountId): string => accountId.toString()) }) as string[]; - const recentlyOnline = useCall(api.derive.imOnline.receivedHeartbeats, []); + const recentlyOnline = useCall(api.derive.imOnline?.receivedHeartbeats, []); const stakingOverview = useCall(api.derive.staking.overview, []); const sessionRewards = useSessionRewards(MAX_SESSIONS); const hasQueries = hasAccounts && !!(api.query.imOnline?.authoredBlocks);