Convert TokenMenuDropdown to an ES6 class (#7779)

feature/default_network_editable
Whymarrh Whitby 5 years ago committed by GitHub
parent be3ba68e4c
commit 3b1cd1286f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 54
      ui/app/components/app/dropdowns/token-menu-dropdown.js

@ -1,45 +1,28 @@
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import { inherits } from 'util'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import * as actions from '../../../store/actions' import * as actions from '../../../store/actions'
import { createAccountLink as genAccountLink } from 'etherscan-link' import { createAccountLink as genAccountLink } from 'etherscan-link'
import { Menu, Item, CloseArea } from './components/menu' import { Menu, Item, CloseArea } from './components/menu'
TokenMenuDropdown.contextTypes = { class TokenMenuDropdown extends Component {
static contextTypes = {
t: PropTypes.func, t: PropTypes.func,
}
export default connect(mapStateToProps, mapDispatchToProps)(TokenMenuDropdown)
function mapStateToProps (state) {
return {
network: state.metamask.network,
} }
}
function mapDispatchToProps (dispatch) { static propTypes = {
return { onClose: PropTypes.func.isRequired,
showHideTokenConfirmationModal: (token) => { showHideTokenConfirmationModal: PropTypes.func.isRequired,
dispatch(actions.showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token })) token: PropTypes.object.isRequired,
}, network: PropTypes.number.isRequired,
} }
}
inherits(TokenMenuDropdown, Component) onClose = (e) => {
function TokenMenuDropdown () {
Component.call(this)
this.onClose = this.onClose.bind(this)
}
TokenMenuDropdown.prototype.onClose = function (e) {
e.stopPropagation() e.stopPropagation()
this.props.onClose() this.props.onClose()
} }
TokenMenuDropdown.prototype.render = function TokenMenuDropdown () { render () {
const { showHideTokenConfirmationModal } = this.props const { showHideTokenConfirmationModal } = this.props
return ( return (
@ -64,4 +47,21 @@ TokenMenuDropdown.prototype.render = function TokenMenuDropdown () {
/> />
</Menu> </Menu>
) )
}
}
export default connect(mapStateToProps, mapDispatchToProps)(TokenMenuDropdown)
function mapStateToProps (state) {
return {
network: state.metamask.network,
}
}
function mapDispatchToProps (dispatch) {
return {
showHideTokenConfirmationModal: (token) => {
dispatch(actions.showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token }))
},
}
} }

Loading…
Cancel
Save