Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Remove unnecessary withRouter and compose calls (MetaMask#7890)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
Gudahtt authored and yqrashawn committed Feb 3, 2020
1 parent 7437d47 commit bbaf6da
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -13,9 +12,10 @@ function mapDispatchToProps (dispatch) {
}
}

const AccountDetailsContainer = compose(connect(null, mapDispatchToProps))(
AccountDetails
)
const AccountDetailsContainer = connect(
null,
mapDispatchToProps
)(AccountDetails)

AccountDetailsContainer.propTypes = {
label: PropTypes.string.isRequired,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { connect } from 'react-redux'
import { compose } from 'recompose'

import ConnectedSitesList from './connected-sites-list.component'
import {
Expand Down Expand Up @@ -52,6 +51,4 @@ const mapDispatchToProps = dispatch => {
}
}

export default compose(connect(mapStateToProps, mapDispatchToProps))(
ConnectedSitesList
)
export default connect(mapStateToProps, mapDispatchToProps)(ConnectedSitesList)
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -25,7 +23,4 @@ const mapStateToProps = (state, ownProps) => {
}
}

export default compose(
withRouter,
connect(mapStateToProps)
)(PermissionPageContainer)
export default connect(mapStateToProps)(PermissionPageContainer)
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -66,7 +64,8 @@ function mergeProps (stateProps, dispatchProps, ownProps) {
}
}

export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps, mergeProps)
export default connect(
mapStateToProps,
mapDispatchToProps,
mergeProps
)(SignatureRequest)
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -54,7 +52,8 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
}
}

export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps, mergeProps)
export default connect(
mapStateToProps,
mapDispatchToProps,
mergeProps
)(TransactionList)
Original file line number Diff line number Diff line change
@@ -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 } from '../../../selectors/transactions'
import {
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions ui/app/helpers/higher-order-components/i18n-provider.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -70,4 +68,4 @@ const mapStateToProps = state => {
}
}

export default compose(withRouter, connect(mapStateToProps))(I18nProvider)
export default connect(mapStateToProps)(I18nProvider)
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -82,8 +81,9 @@ const mapDispatchToProps = dispatch => {
}
}

const PermissionApprovalContainer = compose(
connect(mapStateToProps, mapDispatchToProps)
const PermissionApprovalContainer = connect(
mapStateToProps,
mapDispatchToProps
)(PermissionApproval)

PermissionApprovalContainer.propTypes = {
Expand Down
5 changes: 1 addition & 4 deletions ui/app/pages/settings/settings-tab/settings-tab.container.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SettingsTab from './settings-tab.component'
import { compose } from 'recompose'
import { connect } from 'react-redux'
import {
setCurrentCurrency,
Expand Down Expand Up @@ -48,6 +47,4 @@ const mapDispatchToProps = dispatch => {
}
}

export default compose(connect(mapStateToProps, mapDispatchToProps))(
SettingsTab
)
export default connect(mapStateToProps, mapDispatchToProps)(SettingsTab)
4 changes: 2 additions & 2 deletions ui/app/pages/settings/settings.component.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -240,4 +240,4 @@ class SettingsPage extends PureComponent {
}
}

export default withRouter(SettingsPage)
export default SettingsPage

0 comments on commit bbaf6da

Please sign in to comment.