Skip to content

Commit

Permalink
Remove unnecessary withRouter and compose calls (#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 Jan 24, 2020
1 parent 70a6894 commit b90b30f
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 49 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,7 @@ 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 @@ -22,7 +20,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,4 @@ function mergeProps (stateProps, dispatchProps, ownProps) {
}
}

export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps, mergeProps)
)(SignatureRequest)
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 @@ -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)
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,
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
8 changes: 1 addition & 7 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 @@ -59,8 +57,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 @@ -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,
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 @@ -44,6 +43,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 @@ -244,4 +244,4 @@ class SettingsPage extends PureComponent {
}
}

export default withRouter(SettingsPage)
export default SettingsPage

0 comments on commit b90b30f

Please sign in to comment.