From b90b30f706f9be9c730e516a362baf5647bf20a5 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 24 Jan 2020 15:12:49 -0400 Subject: [PATCH] Remove unnecessary `withRouter` and `compose` calls (#7890) `withRouter` has been removed from any components that were not using any of the three props injected by `withRouter`: `history`, `location`, and `match`. `compose` is a no-op when called upon a single component, so it has been removed in all such cases. --- .../app/account-details/account-details.container.js | 5 +---- .../connected-sites-list.container.js | 5 +---- .../permission-page-container.container.js | 7 +------ .../app/signature-request/signature-request.container.js | 7 +------ .../app/transaction-list/transaction-list.container.js | 7 +------ .../transaction-time-remaining.container.js | 7 +------ ui/app/helpers/higher-order-components/i18n-provider.js | 8 +------- .../permissions-connect/permissions-connect.container.js | 5 +---- .../pages/settings/settings-tab/settings-tab.container.js | 5 +---- ui/app/pages/settings/settings.component.js | 4 ++-- 10 files changed, 11 insertions(+), 49 deletions(-) diff --git a/ui/app/components/app/account-details/account-details.container.js b/ui/app/components/app/account-details/account-details.container.js index 11b143653095..eb1a1a1e1d89 100644 --- a/ui/app/components/app/account-details/account-details.container.js +++ b/ui/app/components/app/account-details/account-details.container.js @@ -1,5 +1,4 @@ import { connect } from 'react-redux' -import { compose } from 'recompose' import PropTypes from 'prop-types' import { hideSidebar, showModal } from '../../../store/actions' import AccountDetails from './account-details.component' @@ -13,9 +12,7 @@ function mapDispatchToProps (dispatch) { } } -const AccountDetailsContainer = compose( - connect(null, mapDispatchToProps) -)(AccountDetails) +const AccountDetailsContainer = connect(null, mapDispatchToProps)(AccountDetails) AccountDetailsContainer.propTypes = { label: PropTypes.string.isRequired, diff --git a/ui/app/components/app/connected-sites-list/connected-sites-list.container.js b/ui/app/components/app/connected-sites-list/connected-sites-list.container.js index de45831a9df7..1058152e153e 100644 --- a/ui/app/components/app/connected-sites-list/connected-sites-list.container.js +++ b/ui/app/components/app/connected-sites-list/connected-sites-list.container.js @@ -1,5 +1,4 @@ import { connect } from 'react-redux' -import { compose } from 'recompose' import ConnectedSitesList from './connected-sites-list.component' import { @@ -52,6 +51,4 @@ const mapDispatchToProps = dispatch => { } } -export default compose( - connect(mapStateToProps, mapDispatchToProps) -)(ConnectedSitesList) +export default connect(mapStateToProps, mapDispatchToProps)(ConnectedSitesList) diff --git a/ui/app/components/app/permission-page-container/permission-page-container.container.js b/ui/app/components/app/permission-page-container/permission-page-container.container.js index f83393c70e11..e8c97cd04ce9 100644 --- a/ui/app/components/app/permission-page-container/permission-page-container.container.js +++ b/ui/app/components/app/permission-page-container/permission-page-container.container.js @@ -1,6 +1,4 @@ import { connect } from 'react-redux' -import { compose } from 'recompose' -import { withRouter } from 'react-router-dom' import PermissionPageContainer from './permission-page-container.component' import { getPermissionsDescriptions, @@ -22,7 +20,4 @@ const mapStateToProps = (state, ownProps) => { } } -export default compose( - withRouter, - connect(mapStateToProps) -)(PermissionPageContainer) +export default connect(mapStateToProps)(PermissionPageContainer) diff --git a/ui/app/components/app/signature-request/signature-request.container.js b/ui/app/components/app/signature-request/signature-request.container.js index 0b09c1a645ef..d28cc89b96c1 100644 --- a/ui/app/components/app/signature-request/signature-request.container.js +++ b/ui/app/components/app/signature-request/signature-request.container.js @@ -1,6 +1,4 @@ import { connect } from 'react-redux' -import { withRouter } from 'react-router-dom' -import { compose } from 'recompose' import SignatureRequest from './signature-request.component' import { goHome } from '../../../store/actions' import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck' @@ -66,7 +64,4 @@ function mergeProps (stateProps, dispatchProps, ownProps) { } } -export default compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps, mergeProps) -)(SignatureRequest) +export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SignatureRequest) diff --git a/ui/app/components/app/transaction-list/transaction-list.container.js b/ui/app/components/app/transaction-list/transaction-list.container.js index 4da044b2ad63..0695c28c2451 100644 --- a/ui/app/components/app/transaction-list/transaction-list.container.js +++ b/ui/app/components/app/transaction-list/transaction-list.container.js @@ -1,6 +1,4 @@ import { connect } from 'react-redux' -import { withRouter } from 'react-router-dom' -import { compose } from 'recompose' import TransactionList from './transaction-list.component' import { nonceSortedCompletedTransactionsSelector, @@ -45,7 +43,4 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { } } -export default compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps, mergeProps) -)(TransactionList) +export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(TransactionList) diff --git a/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js b/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js index 65eeaa0c3953..a9ed6f4dce0f 100644 --- a/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js +++ b/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js @@ -1,6 +1,4 @@ import { connect } from 'react-redux' -import { withRouter } from 'react-router-dom' -import { compose } from 'recompose' import TransactionTimeRemaining from './transaction-time-remaining.component' import { getTxParams, @@ -31,10 +29,7 @@ const mapStateToProps = (state, ownProps) => { } } -export default compose( - withRouter, - connect(mapStateToProps) -)(TransactionTimeRemaining) +export default connect(mapStateToProps)(TransactionTimeRemaining) function calcCustomGasPrice (customGasPriceInHex) { return Number(hexWEIToDecGWEI(customGasPriceInHex)) diff --git a/ui/app/helpers/higher-order-components/i18n-provider.js b/ui/app/helpers/higher-order-components/i18n-provider.js index 33f7ab8627f7..3add2ad85974 100644 --- a/ui/app/helpers/higher-order-components/i18n-provider.js +++ b/ui/app/helpers/higher-order-components/i18n-provider.js @@ -1,8 +1,6 @@ import { Component } from 'react' import { connect } from 'react-redux' import PropTypes from 'prop-types' -import { withRouter } from 'react-router-dom' -import { compose } from 'recompose' import { getMessage } from '../utils/i18n-helper' class I18nProvider extends Component { @@ -59,8 +57,4 @@ const mapStateToProps = state => { } } -export default compose( - withRouter, - connect(mapStateToProps) -)(I18nProvider) - +export default connect(mapStateToProps)(I18nProvider) diff --git a/ui/app/pages/permissions-connect/permissions-connect.container.js b/ui/app/pages/permissions-connect/permissions-connect.container.js index f1fdb17ec9d2..0210be5250ee 100644 --- a/ui/app/pages/permissions-connect/permissions-connect.container.js +++ b/ui/app/pages/permissions-connect/permissions-connect.container.js @@ -1,5 +1,4 @@ import { connect } from 'react-redux' -import { compose } from 'recompose' import PropTypes from 'prop-types' import PermissionApproval from './permissions-connect.component' import { @@ -63,9 +62,7 @@ const mapDispatchToProps = dispatch => { } } -const PermissionApprovalContainer = compose( - connect(mapStateToProps, mapDispatchToProps) -)(PermissionApproval) +const PermissionApprovalContainer = connect(mapStateToProps, mapDispatchToProps)(PermissionApproval) PermissionApprovalContainer.propTypes = { history: PropTypes.object.isRequired, diff --git a/ui/app/pages/settings/settings-tab/settings-tab.container.js b/ui/app/pages/settings/settings-tab/settings-tab.container.js index 96fad9ffcf37..90a1c5e6ade7 100644 --- a/ui/app/pages/settings/settings-tab/settings-tab.container.js +++ b/ui/app/pages/settings/settings-tab/settings-tab.container.js @@ -1,5 +1,4 @@ import SettingsTab from './settings-tab.component' -import { compose } from 'recompose' import { connect } from 'react-redux' import { setCurrentCurrency, @@ -44,6 +43,4 @@ const mapDispatchToProps = dispatch => { } } -export default compose( - connect(mapStateToProps, mapDispatchToProps) -)(SettingsTab) +export default connect(mapStateToProps, mapDispatchToProps)(SettingsTab) diff --git a/ui/app/pages/settings/settings.component.js b/ui/app/pages/settings/settings.component.js index f52b5fdedfeb..7c04057226b5 100644 --- a/ui/app/pages/settings/settings.component.js +++ b/ui/app/pages/settings/settings.component.js @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' -import { Switch, Route, matchPath, withRouter } from 'react-router-dom' +import { Switch, Route, matchPath } from 'react-router-dom' import TabBar from '../../components/app/tab-bar' import c from 'classnames' import SettingsTab from './settings-tab' @@ -244,4 +244,4 @@ class SettingsPage extends PureComponent { } } -export default withRouter(SettingsPage) +export default SettingsPage