Skip to content

Commit

Permalink
chore(components): Prevented render object and report error
Browse files Browse the repository at this point in the history
  • Loading branch information
donskov committed Jun 7, 2020
1 parent 2b4f610 commit da2b4e3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/components/info/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const InfoContainer = styled.div`
`;

export default class Info extends Component {

static contextTypes = {
dispatch: PropTypes.func,
handleRootAction: PropTypes.func,
Expand Down Expand Up @@ -106,6 +105,10 @@ export default class Info extends Component {
return item;
}

componentDidCatch(error) {
console.error(error);
}

renderInfoContent(type, item) {
switch (type) {
case 'certificate':
Expand Down
17 changes: 12 additions & 5 deletions src/components/info/info_certificate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ const CertificateInfo = (props, context) => {

const renderRowContainer = (title, value, index, monospace) => {
if (value && title !== 'name') {
const isLink = value.toString().indexOf('http') === 0;
let valueElement = value;

if (Object.prototype.toString.call(valueElement) === '[object Object]') {
valueElement = null;
}

return (
<RowCertInfo
key={index}
Expand All @@ -21,11 +28,11 @@ const CertificateInfo = (props, context) => {
{title}{title === 'None' ? '' : ':'}
</ColCert>
<ColCert monospace={monospace}>
{value.toString().indexOf('http') === 0 ? (
<a href={value} target="_blank" rel="noopener noreferrer">
{value}
{isLink ? (
<a href={valueElement} target="_blank" rel="noopener noreferrer">
{valueElement}
</a>
) : value}
) : valueElement}
</ColCert>
</RowCertInfo>
);
Expand Down Expand Up @@ -126,7 +133,7 @@ const CertificateInfo = (props, context) => {
</RowCert>
)}
</Row>
</Root >
</Root>
);
};

Expand Down
8 changes: 7 additions & 1 deletion src/components/info/info_request.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ const RequestInfo = (props, context) => {

const renderRowContainer = (title, value, monospace) => {
if (value && title !== 'name') {
let valueElement = value;

if (Object.prototype.toString.call(valueElement) === '[object Object]') {
valueElement = null;
}

return (
<RowCertInfo>
<ColCert>
{title}:
</ColCert>
<ColCert monospace={monospace}>
{value}
{valueElement}
</ColCert>
</RowCertInfo>
);
Expand Down

0 comments on commit da2b4e3

Please sign in to comment.