forked from benmvp/react-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmailView.js
38 lines (33 loc) · 1.03 KB
/
EmailView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from 'react';
import {EMAIL_PROP_TYPE} from './constants';
export default class EmailView extends React.Component {
static propTypes = {
email: EMAIL_PROP_TYPE.isRequired,
onClose: React.PropTypes.func.isRequired,
onDelete: React.PropTypes.func.isRequired
}
_handleClose(e) {
e.stopPropagation();
this.props.onClose();
}
_handleDelete(e) {
e.stopPropagation();
this.props.onDelete();
}
render() {
let {
email: {subject, from, date, message}
} = this.props;
let rawMessage = {__html: message};
return (
<div>
<h1>{subject}</h1>
<h2>From: <a href={`mailto:${from}`}>{from}</a></h2>
<h3>{date}</h3>
<div dangerouslySetInnerHTML={rawMessage} />
<button onClick={this._handleDelete.bind(this)}>Delete</button>
<button onClick={this._handleClose.bind(this)}>Close</button>
</div>
);
}
}