Getting the value of highlighted/marked text

Viewed 82

I'm really new to React Native (but quite experienced in React) and i'm having some issues with my react native app and was hoping to get some help.

What i'm trying to achieve is that I want to be able to select and highlight a word in a text, then store that value in a variable.

In native javascript to retrive the word would be something like "window.getSelection()", but that obviously doesnt work in this case. At the moment I have only found solutions using TextInput, but I want the text to be static.

Anyone have any suggestions how to tackle this problem?

Thank you in advance

1 Answers

Use <TextInput> with a editable={false}

UPDATE

As far as I know, there is no way to get the highlighted string directly but you can handle this with a trick! use a setInterval and call Clipboard.getString() to get the string that is copied to clipboard!

ref1 - ref2

Related