Skip to content

Commit df17187

Browse files
committed
Move detectNfts dispatch call out of component library and into account-overview-tabs to isolate presentational abstraction away from business logic
1 parent cfcc492 commit df17187

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

ui/components/multichain/account-overview/account-overview-tabs.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useCallback, useContext, useMemo } from 'react';
2+
import { useDispatch } from 'react-redux';
23
import { useHistory } from 'react-router-dom';
34
import { endTrace, trace } from '../../../../shared/lib/trace';
45
import { useI18nContext } from '../../../hooks/useI18nContext';
@@ -40,6 +41,7 @@ import {
4041
ACCOUNT_OVERVIEW_TAB_KEY_TO_TRACE_NAME_MAP,
4142
AccountOverviewTabKey,
4243
} from '../../../../shared/constants/app-state';
44+
import { detectNfts } from '../../../store/actions';
4345
import { AccountOverviewCommonProps } from './common';
4446

4547
export type AccountOverviewTabsProps = AccountOverviewCommonProps & {
@@ -63,6 +65,7 @@ export const AccountOverviewTabs = ({
6365
const history = useHistory();
6466
const t = useI18nContext();
6567
const trackEvent = useContext(MetaMetricsContext);
68+
const dispatch = useDispatch();
6669

6770
const tabProps = useMemo(
6871
() => ({
@@ -75,6 +78,9 @@ export const AccountOverviewTabs = ({
7578
const handleTabClick = useCallback(
7679
(tabName: AccountOverviewTabKey) => {
7780
onTabClick(tabName);
81+
if (tabName === AccountOverviewTabKey.Nfts) {
82+
dispatch(detectNfts());
83+
}
7884
trackEvent({
7985
category: MetaMetricsEventCategory.Home,
8086
event: ACCOUNT_OVERVIEW_TAB_KEY_TO_METAMETRICS_EVENT_NAME_MAP[tabName],

ui/components/ui/tabs/tabs.component.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
33
import classnames from 'classnames';
4-
import { useDispatch } from 'react-redux';
54
import Box from '../box';
65
import {
76
BackgroundColor,
87
DISPLAY,
98
JustifyContent,
109
} from '../../../helpers/constants/design-system';
11-
import { detectNfts } from '../../../store/actions';
1210

1311
const Tabs = ({
1412
defaultActiveTabKey,
@@ -22,7 +20,6 @@ const Tabs = ({
2220
const _getValidChildren = () => {
2321
return React.Children.toArray(children).filter(Boolean);
2422
};
25-
const dispatch = useDispatch();
2623

2724
/**
2825
* Returns the index of the child with the given key
@@ -44,10 +41,6 @@ const Tabs = ({
4441
setActiveTabIndex(tabIndex);
4542
onTabClick?.(tabKey);
4643
}
47-
48-
if (tabKey === 'nfts') {
49-
dispatch(detectNfts());
50-
}
5144
};
5245

5346
const renderTabs = () => {

0 commit comments

Comments
 (0)