2017-08-10 01:56:27 +00:00
|
|
|
import React, {PureComponent} from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-03-03 01:44:07 +00:00
|
|
|
import autobind from 'autobind-decorator';
|
2016-09-10 02:51:24 +00:00
|
|
|
|
2017-03-03 01:44:07 +00:00
|
|
|
@autobind
|
2017-02-28 21:32:23 +00:00
|
|
|
class ResponseRaw extends PureComponent {
|
2017-03-03 01:44:07 +00:00
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
2017-03-30 18:52:07 +00:00
|
|
|
this._timeout = null;
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-09-14 23:25:19 +00:00
|
|
|
|
2017-03-03 20:09:08 +00:00
|
|
|
_setTextAreaRef (n) {
|
|
|
|
this._textarea = n;
|
|
|
|
}
|
|
|
|
|
2017-03-30 18:52:07 +00:00
|
|
|
_update (value) {
|
|
|
|
clearTimeout(this._timeout);
|
|
|
|
this._timeout = setTimeout(() => {
|
|
|
|
if (this._textarea) {
|
|
|
|
this._textarea.value = value;
|
|
|
|
}
|
|
|
|
}, 200);
|
2016-09-10 02:51:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate () {
|
2017-03-03 20:09:08 +00:00
|
|
|
this._update(this.props.value);
|
2016-09-10 02:51:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
2017-03-03 20:09:08 +00:00
|
|
|
this._update(this.props.value);
|
2016-09-10 02:51:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
shouldComponentUpdate (nextProps) {
|
|
|
|
for (let key in nextProps) {
|
|
|
|
if (nextProps.hasOwnProperty(key)) {
|
|
|
|
if (nextProps[key] !== this.props[key]) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {fontSize} = this.props;
|
|
|
|
return (
|
|
|
|
<textarea
|
2017-03-03 20:09:08 +00:00
|
|
|
ref={this._setTextAreaRef}
|
2016-09-10 02:51:24 +00:00
|
|
|
placeholder="..."
|
|
|
|
className="force-wrap scrollable wide tall selectable monospace pad no-resize"
|
2017-03-01 21:15:56 +00:00
|
|
|
readOnly
|
2016-09-10 02:51:24 +00:00
|
|
|
defaultValue=""
|
|
|
|
style={{fontSize}}>
|
|
|
|
</textarea>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ResponseRaw.propTypes = {
|
|
|
|
value: PropTypes.string.isRequired,
|
|
|
|
fontSize: PropTypes.number
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ResponseRaw;
|