import React from 'react'; import { connect } from 'react-redux'; class CommentsForm extends React.Component { constructor(props){ super(props); this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit(event){ event.preventDefault(); this.props.handleSubmit(this.refs.comment.value); } render() { return
} } const mapDispatchToProps = function(dispatch){ return { handleSubmit: function(body){ dispatch({type:'ADD', comment: body }); } } } const VisibleCommentsForm = connect( null, mapDispatchToProps )(CommentsForm) export default VisibleCommentsForm;