A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/development/selector.js

50 lines
1.3 KiB

import PropTypes from 'prop-types'
5 years ago
import React, { Component } from 'react'
export default class Selector extends Component {
state = {}
render () {
const {
states,
selectedKey,
updateState,
store,
modifyBackgroundConnection,
backGroundConnectionModifiers,
} = this.props
const selected = this.state.selected || selectedKey
return (
<select
style={{ margin: '20px 20px 0px' }}
value={selected}
onChange={(event) => {
const selectedKey = event.target.value
const backgroundConnectionModifier = backGroundConnectionModifiers[selectedKey]
modifyBackgroundConnection(backgroundConnectionModifier || {})
store.dispatch(updateState(selectedKey))
this.setState({ selected: selectedKey })
}}
>
{Object.keys(states).map((stateName, index) => {
return (
<option key={index} value={stateName}>
{stateName}
</option>
)
})}
</select>
)
}
}
Selector.propTypes = {
states: PropTypes.object.isRequired,
selectedKey: PropTypes.string.isRequired,
updateState: PropTypes.func.isRequired,
store: PropTypes.object.isRequired,
modifyBackgroundConnection: PropTypes.func.isRequired,
backGroundConnectionModifiers: PropTypes.object.isRequired,
}