Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import React from 'react';
import { connect } from 'react-redux';
class NewComment extends React.Component {
input = null
writeComment = evt => {
const comment = this.input.value;
comment && this.props.dispatch({ type: 'WRITE_COMMENT', comment });
render() {
const { id, content } = this.props.comment;
return (
<input type="text" ref={e => this.input = e} placeholder="Write a comment" />
<button type="button" onClick={this.writeComment}>Submit Comment</button>
export default connect()(NewComment);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.