-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathCommentEditWidget.js
More file actions
43 lines (38 loc) · 1013 Bytes
/
CommentEditWidget.js
File metadata and controls
43 lines (38 loc) · 1013 Bytes
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
39
40
41
42
43
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { injectIntl, FormattedMessage } from 'react-intl';
// Import Style
import styles from './CommentEditWidget.css';
export class CommentEditWidget extends Component {
updateComment = () => {
const contentRef = this.refs.content;
if (contentRef.value) {
this.props.onUpdate(contentRef.value);
}
};
render() {
return (
<div>
<textarea
className={styles['form-field']}
ref="content"
defaultValue={this.props.comment.content}
/>
<a
className={styles['post-submit-button']}
href="#"
onClick={this.updateComment}
>
<FormattedMessage id="submit" />
</a>
</div>
);
}
}
CommentEditWidget.propTypes = {
onUpdate: PropTypes.func.isRequired,
comment: PropTypes.shape({
content: PropTypes.string.isRequired,
}).isRequired,
};
export default injectIntl(CommentEditWidget);