Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created August 29, 2018 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gladchinda/66c11f0d645910cdd84f4238a035a724 to your computer and use it in GitHub Desktop.
Save gladchinda/66c11f0d645910cdd84f4238a035a724 to your computer and use it in GitHub Desktop.
import React from 'react';
import { connect } from 'react-redux';
class NewComment extends React.Component {
input = null
writeComment = evt => {
evt.preventDefault();
const comment = this.input.value;
comment && this.props.dispatch({ type: 'WRITE_COMMENT', comment });
}
render() {
const { id, content } = this.props.comment;
return (
<div>
<input type="text" ref={e => this.input = e} placeholder="Write a comment" />
<button type="button" onClick={this.writeComment}>Submit Comment</button>
</div>
)
}
}
export default connect()(NewComment);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment