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 React, { Component } from 'react'
import { inherits } from 'util'
import { connect } from 'react-redux'
import * as actions from '../../../store/actions'
import { createAccountLink as genAccountLink } from 'etherscan-link'
import { Menu, Item, CloseArea } from './components/menu'
TokenMenuDropdown.contextTypes = {
class TokenMenuDropdown extends Component {
static contextTypes = {
t: PropTypes.func,
}
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 }))
},
static propTypes = {
onClose: PropTypes.func.isRequired,
showHideTokenConfirmationModal: PropTypes.func.isRequired,
token: PropTypes.object.isRequired,
network: PropTypes.number.isRequired,
}
}
inherits(TokenMenuDropdown, Component)
function TokenMenuDropdown () {
Component.call(this)
this.onClose = this.onClose.bind(this)
}
TokenMenuDropdown.prototype.onClose = function (e) {
onClose = (e) => {
e.stopPropagation()
this.props.onClose()
}
}
TokenMenuDropdown.prototype.render = function TokenMenuDropdown () {
render () {
const { showHideTokenConfirmationModal } = this.props
return (
@ -64,4 +47,21 @@ TokenMenuDropdown.prototype.render = function TokenMenuDropdown () {
/>
</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