I have a textbox where a user enters text. A search for specific keywords is then performed and the string is split at these keywords.
A first input may look like E.g.
[
0: "this is "
1: "word"
2: " a form field value with another "
3: "word"
]
A change then might be made to remove the first repeated word:
[
0: "this is "
1: " a form field value with another "
2: "word"
]
How can I create a persistent key for each array item? I need the second word value to have the same React key as when it is first generated regardless of array position. It is a separate component instance regardless of the same value. I have an issue right now where deleting one of the split words will delete both due to the keys changing after the first word is deleted.
Best practices say not to use the array index, but I'm unsure in this situation how else to generate a unique key.
${index}${value}