From 9f8abab871f28b12c3eca00a706b9ed8b913c1a6 Mon Sep 17 00:00:00 2001 From: Andy Kleindienst Date: Fri, 27 Oct 2023 09:56:30 -0400 Subject: [PATCH] add optional chaining operator to organization and guide information to prevent string methods from trying to execute with a null value --- src/js/pages/Values/OneValue.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/js/pages/Values/OneValue.jsx b/src/js/pages/Values/OneValue.jsx index f0535c15b..d74813740 100755 --- a/src/js/pages/Values/OneValue.jsx +++ b/src/js/pages/Values/OneValue.jsx @@ -211,18 +211,18 @@ class OneValue extends Component { }); organizationsForValue = filter(organizationsForValueModified, (organization) => ( - organization.organization_name.toLowerCase().includes(searchTextLowercase) || - organization.twitter_description.toLowerCase().includes(searchTextLowercase) || - organization.organization_twitter_handle.toLowerCase().includes(searchTextLowercase) + organization.organization_name?.toLowerCase().includes(searchTextLowercase) || + organization.twitter_description?.toLowerCase().includes(searchTextLowercase) || + organization.organization_twitter_handle?.toLowerCase().includes(searchTextLowercase) )); organizationsForValueLength = organizationsForValue.length; organizationListIdentifier = `${valueSlug}${organizationsForValueLength}`; } if (showEndorsersForThisElection) { voterGuidesForValue = filter(voterGuidesForValue, - (guide) => guide.voter_guide_display_name.toLowerCase().includes(searchTextLowercase) || - guide.twitter_description.toLowerCase().includes(searchTextLowercase) || - guide.twitter_handle.toLowerCase().includes(searchTextLowercase)); + (guide) => guide.voter_guide_display_name?.toLowerCase().includes(searchTextLowercase) || + guide.twitter_description?.toLowerCase().includes(searchTextLowercase) || + guide.twitter_handle?.toLowerCase().includes(searchTextLowercase)); } }