fix: non-json sample crash in some cases

fixes #456
This commit is contained in:
Roman Hotsiy 2018-06-01 18:20:27 +03:00
parent 63ae2e8e94
commit 209c6caca0
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -21,9 +21,10 @@ export class MediaTypeSamples extends React.Component<PayloadSamplesProps> {
const sampleView = isJsonLike(mimeType)
? sample => <JsonViewer data={sample} />
: sample =>
(sample && <SourceCodeWithCopy lang={langFromMime(mimeType)} source={sample} />) || {
noSample,
};
(sample !== undefined && (
<SourceCodeWithCopy lang={langFromMime(mimeType)} source={sample} />
)) ||
noSample;
const examplesNames = Object.keys(examples);
if (examplesNames.length === 0) {