mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Raw textarea now async
This commit is contained in:
parent
dabf153e92
commit
fe48b40ce7
50
app/components/viewers/ResponseRaw.js
Normal file
50
app/components/viewers/ResponseRaw.js
Normal file
@ -0,0 +1,50 @@
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
|
||||
class ResponseRaw extends Component {
|
||||
_update (value) {
|
||||
setTimeout(() => {
|
||||
this._textarea.value = value;
|
||||
}, 50)
|
||||
}
|
||||
|
||||
componentDidUpdate () {
|
||||
this._update(this.props.value)
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
this._update(this.props.value)
|
||||
}
|
||||
|
||||
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
|
||||
ref={n => this._textarea = n}
|
||||
placeholder="..."
|
||||
className="force-wrap scrollable wide tall selectable monospace pad no-resize"
|
||||
readOnly={true}
|
||||
defaultValue=""
|
||||
style={{fontSize}}>
|
||||
</textarea>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ResponseRaw.propTypes = {
|
||||
value: PropTypes.string.isRequired,
|
||||
fontSize: PropTypes.number
|
||||
};
|
||||
|
||||
export default ResponseRaw;
|
@ -1,6 +1,7 @@
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import Editor from '../base/Editor';
|
||||
import ResponseWebview from './ResponseWebview';
|
||||
import ResponseRaw from './ResponseRaw';
|
||||
import ResponseError from './ResponseError';
|
||||
import {
|
||||
PREVIEW_MODE_FRIENDLY,
|
||||
@ -62,10 +63,10 @@ class ResponseViewer extends Component {
|
||||
);
|
||||
default: // Raw
|
||||
return (
|
||||
<textarea className="scrollable wide tall selectable monospace pad no-resize"
|
||||
defaultValue={body}
|
||||
style={{fontSize: editorFontSize}}>
|
||||
</textarea>
|
||||
<ResponseRaw
|
||||
value={body}
|
||||
fontSize={editorFontSize}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user