From 82bc8756c41a16684d19aa2ef79b3d9e9748d76c Mon Sep 17 00:00:00 2001 From: Pedro Brion <93540165+Brion-bitzen@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:44:41 -0300 Subject: [PATCH] Correcting error on open on chevron When you open, then close whitout selecting any item and open again, it throws a error ("undefined.length is not a function") --- src/ScrollViewListItem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ScrollViewListItem.js b/src/ScrollViewListItem.js index 7959d43..9b2f224 100644 --- a/src/ScrollViewListItem.js +++ b/src/ScrollViewListItem.js @@ -7,12 +7,12 @@ export const ScrollViewListItem = memo(({ highlight, title, style, onPress, numb let titleStart = title let titleEnd = '' - if (typeof title === 'string' && title.length > 0 && highlight.length > 0) { + if (typeof title === 'string' && title?.length > 0 && highlight?.length > 0) { const substrIndex = title.toLowerCase().indexOf(highlight.toLowerCase()) if (substrIndex !== -1) { titleStart = title.slice(0, substrIndex) - titleHighlighted = title.slice(substrIndex, substrIndex + highlight.length) - titleEnd = title.slice(substrIndex + highlight.length) + titleHighlighted = title.slice(substrIndex, substrIndex + highlight?.length) + titleEnd = title.slice(substrIndex + highlight?.length) } }