Refactor Talk component and ref handler.

pull/1887/head
Hunter Trujillo 2017-08-15 15:54:21 -06:00 committed by Andrew Watkins
parent f0c05f083c
commit 4c56ec5e6a
1 changed files with 24 additions and 18 deletions

View File

@ -1,21 +1,13 @@
import React, {PropTypes} from 'react'
import React, {PropTypes, Component} from 'react'
import RedactedInput from './RedactedInput'
const {bool, string, shape, func} = PropTypes
class TalkConfig extends Component {
constructor(props) {
super(props)
}
const TalkConfig = React.createClass({
propTypes: {
config: shape({
options: shape({
url: bool.isRequired,
author_name: string.isRequired,
}).isRequired,
}).isRequired,
onSave: func.isRequired,
},
handleSaveAlert(e) {
handleSaveAlert = e => {
e.preventDefault()
const properties = {
@ -24,7 +16,9 @@ const TalkConfig = React.createClass({
}
this.props.onSave(properties)
},
}
handleUrlRef = r => (this.url = r)
render() {
const {url, author_name: author} = this.props.config.options
@ -36,7 +30,7 @@ const TalkConfig = React.createClass({
<RedactedInput
defaultValue={url}
id="url"
refFunc={r => (this.url = r)}
refFunc={this.handleUrlRef}
/>
</div>
@ -58,7 +52,19 @@ const TalkConfig = React.createClass({
</div>
</form>
)
},
})
}
}
const {bool, string, shape, func} = PropTypes
TalkConfig.propTypes = {
config: shape({
options: shape({
url: bool.isRequired,
author_name: string.isRequired,
}).isRequired,
}).isRequired,
onSave: func.isRequired,
}
export default TalkConfig