diff options
Diffstat (limited to 'development/selector.js')
-rw-r--r-- | development/selector.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/development/selector.js b/development/selector.js new file mode 100644 index 000000000..b58904cdf --- /dev/null +++ b/development/selector.js @@ -0,0 +1,30 @@ +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', { + 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) + })) + +} |