Skip to content

Instantly share code, notes, and snippets.

@pratik-chakravorty
Last active March 29, 2018 04:19
Show Gist options
  • Save pratik-chakravorty/1fffab368875d23449759d2303a898ec to your computer and use it in GitHub Desktop.
Save pratik-chakravorty/1fffab368875d23449759d2303a898ec to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { connect } from 'react-redux';
class Post extends Component {
render() {
return (
<div className="post">
<h2 className="post_title">{this.props.post.title}</h2>
<p className="post_message">{this.props.post.message}</p>
<div className="control-buttons">
<button className="edit"
onClick={() => this.props.dispatch({ type: 'EDIT_POST', id: this.props.post.id })
}
>Edit</button>
<button className="delete"
onClick={() => this.props.dispatch({ type: 'DELETE_POST', id: this.props.post.id })}
>Delete</button>
</div>
</div>
);
}
}
export default connect()(Post);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment