From ec435166f250731c3077ebc483b3669d32186a1d Mon Sep 17 00:00:00 2001 From: Vu Date: Mon, 10 May 2021 09:22:37 +0700 Subject: [PATCH] fix: 'id' is not passed in onHighlightPress function --- Demo/SelectableText.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Demo/SelectableText.js b/Demo/SelectableText.js index bd6d5d8..0292188 100644 --- a/Demo/SelectableText.js +++ b/Demo/SelectableText.js @@ -36,16 +36,18 @@ const mapHighlightsRanges = (value, highlights) => { const data = [{ isHighlight: false, text: value.slice(0, combinedHighlights[0].start) }] - combinedHighlights.forEach(({ start, end }, idx) => { + combinedHighlights.forEach(({ start, end, id }, idx) => { data.push({ isHighlight: true, text: value.slice(start, end), + id }) if (combinedHighlights[idx + 1]) { data.push({ isHighlight: false, text: value.slice(end, combinedHighlights[idx + 1].start), + id: undefined }) } }) @@ -53,6 +55,7 @@ const mapHighlightsRanges = (value, highlights) => { data.push({ isHighlight: false, text: value.slice(combinedHighlights[combinedHighlights.length - 1].end, value.length), + id: undefined }) return data.filter(x => x.text)