Skip to content

Commit

Permalink
Fix: failure caused by missing value property (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored May 13, 2019
1 parent d8447ef commit 4184b28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
26 changes: 12 additions & 14 deletions src/components/Roles/Class.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ import React from 'react';
import PropTypes from 'prop-types';

const baseUrl = 'https://api.mongodb.com/python/current/api/pymongo/results.html#';
const RoleClass = ({
nodeData: {
label: { value },
target,
},
}) => (
<a href={`${baseUrl}${target}`} className="reference external">
<code className="xref py py-class docutils literal notranslate">
<span className="pre">{value}</span>
</code>
</a>
);
const RoleClass = ({ nodeData: { label, target } }) => {
const labelDisplay = label && label.value ? label.value : target;
return (
<a href={`${baseUrl}${target}`} className="reference external">
<code className="xref py py-class docutils literal notranslate">
<span className="pre">{labelDisplay}</span>
</code>
</a>
);
};

RoleClass.propTypes = {
nodeData: PropTypes.shape({
label: PropTypes.shape({
value: PropTypes.string.isRequired,
}).isRequired,
value: PropTypes.string,
}),
target: PropTypes.string.isRequired,
}).isRequired,
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Roles/Doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const RoleDoc = ({ nodeData: { label, target }, refDocMapping }) => {
RoleDoc.propTypes = {
nodeData: PropTypes.shape({
label: PropTypes.shape({
value: PropTypes.string.isRequired,
value: PropTypes.string,
}),
target: PropTypes.string.isRequired,
}).isRequired,
Expand Down

0 comments on commit 4184b28

Please sign in to comment.