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.
33 lines
837 B
33 lines
837 B
const Component = require('react').Component
|
|
const h = require('react-hyperscript')
|
|
const inherits = require('util').inherits
|
|
|
|
module.exports = NewComponent
|
|
|
|
inherits(NewComponent, Component)
|
|
function NewComponent () {
|
|
Component.call(this)
|
|
}
|
|
|
|
NewComponent.prototype.render = function () {
|
|
const props = this.props
|
|
let { states, selectedKey, actions, store } = props
|
|
|
|
const state = this.state || {}
|
|
const selected = state.selected || selectedKey
|
|
|
|
return h('select', {
|
|
style: {
|
|
margin: '20px 20px 0px',
|
|
},
|
|
value: selected,
|
|
onChange:(event) => {
|
|
const selectedKey = event.target.value
|
|
store.dispatch(actions.update(selectedKey))
|
|
this.setState({ selected: selectedKey })
|
|
},
|
|
}, Object.keys(states).map((stateName) => {
|
|
return h('option', { value: stateName }, stateName)
|
|
}))
|
|
|
|
}
|
|
|