Skip to content

Commit

Permalink
add checks for empty object (#615)
Browse files Browse the repository at this point in the history
Co-authored-by: beets <[email protected]>
  • Loading branch information
chejennifer and beets authored Oct 15, 2020
1 parent d6473ee commit 90c0676
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions static/js/place/place_highlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import React from "react";
import { PageHighlight } from "./types";
import _ from "lodash";

interface PlaceHighlightPropsType {
dcid: string;
Expand All @@ -33,7 +34,13 @@ class PlaceHighlight extends React.Component<PlaceHighlightPropsType, unknown> {
render(): JSX.Element {
const facts = Object.keys(this.props.highlight).map((factTitle: string) => {
const factSnapshot = this.props.highlight[factTitle];
if (_.isEmpty(factSnapshot.data)) {
return null;
}
const factData = factSnapshot.data[0].data;
if (_.isEmpty(factData)) {
return null;
}
const factStatVar = Object.keys(factData)[0];
const factValue = factData[factStatVar];
return (
Expand Down

0 comments on commit 90c0676

Please sign in to comment.