Convert dev scripts to use JSX (#7555)
parent
f5c496ffcd
commit
1501742d68
@ -1,42 +1,49 @@ |
|||||||
const Component = require('react').Component |
import PropTypes from 'prop-types' |
||||||
const h = require('react-hyperscript') |
import React, {Component} from 'react' |
||||||
const inherits = require('util').inherits |
|
||||||
|
|
||||||
module.exports = NewComponent |
export default class Selector extends Component { |
||||||
|
state = {} |
||||||
|
|
||||||
inherits(NewComponent, Component) |
render () { |
||||||
function NewComponent () { |
const { |
||||||
Component.call(this) |
states, |
||||||
} |
selectedKey, |
||||||
|
actions, |
||||||
NewComponent.prototype.render = function () { |
store, |
||||||
const props = this.props |
modifyBackgroundConnection, |
||||||
const { |
backGroundConnectionModifiers, |
||||||
states, |
} = this.props |
||||||
selectedKey, |
const selected = this.state.selected || selectedKey |
||||||
actions, |
|
||||||
store, |
|
||||||
modifyBackgroundConnection, |
|
||||||
backGroundConnectionModifiers, |
|
||||||
} = props |
|
||||||
|
|
||||||
const state = this.state || {} |
return ( |
||||||
const selected = state.selected || selectedKey |
<select |
||||||
|
style={{ margin: '20px 20px 0px' }} |
||||||
return h('select', { |
value={selected} |
||||||
style: { |
onChange={(event) => { |
||||||
margin: '20px 20px 0px', |
const selectedKey = event.target.value |
||||||
}, |
const backgroundConnectionModifier = backGroundConnectionModifiers[selectedKey] |
||||||
value: selected, |
modifyBackgroundConnection(backgroundConnectionModifier || {}) |
||||||
onChange: (event) => { |
store.dispatch(actions.update(selectedKey)) |
||||||
const selectedKey = event.target.value |
this.setState({ selected: selectedKey }) |
||||||
const backgroundConnectionModifier = backGroundConnectionModifiers[selectedKey] |
}} |
||||||
modifyBackgroundConnection(backgroundConnectionModifier || {}) |
> |
||||||
store.dispatch(actions.update(selectedKey)) |
{Object.keys(states).map((stateName, index) => { |
||||||
this.setState({ selected: selectedKey }) |
return ( |
||||||
}, |
<option key={index} value={stateName}> |
||||||
}, Object.keys(states).map((stateName) => { |
{stateName} |
||||||
return h('option', { value: stateName }, stateName) |
</option> |
||||||
})) |
) |
||||||
|
})} |
||||||
|
</select> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Selector.propTypes = { |
||||||
|
states: PropTypes.object.isRequired, |
||||||
|
selectedKey: PropTypes.string.isRequired, |
||||||
|
actions: PropTypes.object.isRequired, |
||||||
|
store: PropTypes.object.isRequired, |
||||||
|
modifyBackgroundConnection: PropTypes.func.isRequired, |
||||||
|
backGroundConnectionModifiers: PropTypes.object.isRequired, |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue