// - Import react components import React, {Component} from 'react' import {connect} from 'react-redux' import Faker from 'faker' // - Import app components // - Import actions import * as commentActions from 'commentActions' // - Define variable const buttonStyle = { marginTop: '5px' } // - Create CommentWrite component class export class CommentWrite extends Component { constructor(props) { super(props) this.state = { inputValue:'' } // Binding functions to `this` this.handleRef = this.handleRef.bind(this) this.focus = this.focus.bind(this) this.handleAddComment = this.handleAddComment.bind(this) this.handleOnChange = this.handleOnChange.bind(this) } handleOnChange = (evt) =>{ this.setState({inputValue:evt.target.value}) } handleRef = c => { this.inputRef = c } focus = () => { this.inputRef.focus() } handleAddComment = (evt) => { this.props.send(this.state.inputValue,this.props.postId,this.props.close) } // Render DOM render() { return (