insomnia/app/components/RequestBodyEditor.js

37 lines
852 B
JavaScript
Raw Normal View History

2016-03-22 05:01:58 +00:00
import React, {Component, PropTypes} from 'react';
2016-04-09 21:41:27 +00:00
import Editor from './base/Editor'
2016-03-22 05:01:58 +00:00
class RequestBodyEditor extends Component {
shouldComponentUpdate (nextProps) {
return this.props.request !== nextProps.request;
}
render () {
const {request, onChange, className} = this.props;
2016-04-15 02:13:49 +00:00
// console.log(request);
// const mode = request.contentType || 'application/json';
const mode = 'application/json';
2016-04-04 07:15:30 +00:00
2016-03-22 05:01:58 +00:00
return (
2016-04-09 21:41:27 +00:00
<Editor
2016-03-22 05:01:58 +00:00
value={request.body}
className={className}
onChange={onChange}
2016-03-23 18:34:39 +00:00
options={{
2016-04-04 07:15:30 +00:00
mode: mode,
2016-03-23 18:34:39 +00:00
placeholder: 'request body here...'
}}
2016-03-22 05:01:58 +00:00
/>
)
}
}
RequestBodyEditor.propTypes = {
request: PropTypes.shape({
2016-04-04 07:15:30 +00:00
body: PropTypes.string.isRequired
2016-03-22 05:01:58 +00:00
}).isRequired,
onChange: PropTypes.func.isRequired
};
export default RequestBodyEditor;