Update RuleMessage to remove anyonymous functions from props

pull/1887/head
Andrew Watkins 2017-08-15 17:33:38 -07:00
parent f29db011e5
commit a70014352e
2 changed files with 13 additions and 7 deletions

View File

@ -12,9 +12,12 @@ class RuleMessageTemplates extends Component {
super(props)
}
render() {
const {rule, updateMessage} = this.props
handleClickTemplate = template => () => {
const {updateMessage, rule} = this.props
updateMessage(rule.id, `${rule.message} ${template.label}`)
}
render() {
return (
<div className="rule-section--row rule-section--row-last rule-section--border-top">
<p>Templates:</p>
@ -23,8 +26,7 @@ class RuleMessageTemplates extends Component {
<CodeData
key={key}
template={template}
onClickTemplate={() =>
updateMessage(rule.id, `${rule.message} ${template.label}`)}
onClickTemplate={this.handleClickTemplate(template)}
/>
)
})}

View File

@ -5,14 +5,18 @@ class RuleMessageText extends Component {
super(props)
}
render() {
handleChange = e => {
const {rule, updateMessage} = this.props
updateMessage(rule, e.targe.value)
}
render() {
const {rule} = this.props
return (
<textarea
className="form-control form-malachite monotype rule-builder--message"
ref={r => (this.message = r)}
onChange={() => updateMessage(rule.id, this.message.value)}
onChange={this.handleChange}
placeholder="Example: {{ .ID }} is {{ .Level }} value: {{ index .Fields &quot;value&quot; }}"
value={rule.message}
spellCheck={false}