Prevent RequestBody from accessing a media type that ceased to exist

This commit is contained in:
Kyle Shockey
2017-11-17 18:45:19 -08:00
parent 44bd85a5bb
commit 33f8338560
2 changed files with 14 additions and 0 deletions

View File

@@ -27,6 +27,16 @@ export default class ContentType extends React.Component {
} }
} }
componentWillReceiveProps(nextProps) {
if(!nextProps.contentTypes || !nextProps.contentTypes.size) {
return
}
if(!nextProps.contentTypes.includes(nextProps.value)) {
nextProps.onChange(nextProps.contentTypes.first())
}
}
onChangeWrapper = e => this.props.onChange(e.target.value) onChangeWrapper = e => this.props.onChange(e.target.value)
render() { render() {

View File

@@ -22,6 +22,10 @@ const RequestBody = ({
const mediaTypeValue = requestBodyContent.get(contentType) const mediaTypeValue = requestBodyContent.get(contentType)
if(!mediaTypeValue) {
return null
}
return <div> return <div>
{ requestBodyDescription && { requestBodyDescription &&
<Markdown source={requestBodyDescription} /> <Markdown source={requestBodyDescription} />