From 1d8613655f63f6fe32ee4304d1dd7bc02ca803ee Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 28 Jan 2020 15:01:18 +0100 Subject: [PATCH] Convert options & items (tabs) to useMemo (#2207) * Convert options & items (tabs) to useMemo * Add missing var in useMemo * Remove floating isSubstrateV2 * Cleanup staking entry * Remove unneeded ? --- packages/app-accounts/src/index.tsx | 25 +++--- packages/app-accounts/src/modals/Create.tsx | 21 +++-- packages/app-address-book/src/index.tsx | 17 ++-- packages/app-council/src/index.tsx | 33 +++---- .../app-democracy/src/Overview/Voting.tsx | 25 ++---- packages/app-democracy/src/index.tsx | 17 ++-- packages/app-explorer/src/index.tsx | 43 +++++----- packages/app-extrinsics/src/index.tsx | 23 +++-- packages/app-generic-asset/src/index.tsx | 37 ++++---- packages/app-parachains/src/index.tsx | 17 ++-- packages/app-settings/src/index.tsx | 25 +++--- packages/app-society/src/index.tsx | 17 ++-- .../src/Actions/Account/InjectKeys.tsx | 44 +++++----- packages/app-staking/src/index.tsx | 86 ++++++++----------- packages/app-storage/src/Selection/index.tsx | 41 ++++----- packages/app-sudo/src/index.tsx | 25 +++--- packages/app-tech-comm/src/index.tsx | 25 +++--- packages/app-toolbox/src/index.tsx | 16 ++-- .../app-treasury/src/Overview/Approve.tsx | 2 +- .../app-treasury/src/Overview/Submission.tsx | 27 +++--- packages/app-treasury/src/index.tsx | 17 ++-- packages/react-params/src/Param/Vote.tsx | 9 +- 22 files changed, 285 insertions(+), 307 deletions(-) diff --git a/packages/app-accounts/src/index.tsx b/packages/app-accounts/src/index.tsx index 99c4c1c76f..9a30ae0520 100644 --- a/packages/app-accounts/src/index.tsx +++ b/packages/app-accounts/src/index.tsx @@ -5,7 +5,7 @@ import { AppProps as Props } from '@polkadot/react-components/types'; import { ComponentProps } from './types'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { Route, Switch } from 'react-router'; import { useAccounts } from '@polkadot/react-hooks'; import { HelpOverlay, Tabs } from '@polkadot/react-components'; @@ -19,6 +19,17 @@ export default function AccountsApp ({ basePath, onStatusChange }: Props): React const { t } = useTranslation(); const { hasAccounts } = useAccounts(); const [hidden, setHidden] = useState(['vanity']); + const items = useMemo(() => [ + { + isRoot: true, + name: 'overview', + text: t('My accounts') + }, + { + name: 'vanity', + text: t('Vanity address') + } + ], [t]); useEffect((): void => { setHidden( @@ -42,17 +53,7 @@ export default function AccountsApp ({ basePath, onStatusChange }: Props): React