Hafiz Muhammad Bilal
Hafiz Muhammad Bilal

Reputation: 315

How to get single word or a range of words in a Text component react native?

Like if I have a whole sentence e.g My name is Bilal Riaz wrapped in a Text component. On tapping Bilal, I want to get(console) it. Moreover, If I long press on Bilal and drag it to the word Riaz, the Bilal Riaz text would be there.

Upvotes: 0

Views: 387

Answers (1)

Hardik prajapati
Hardik prajapati

Reputation: 144

First split the text then after create one array and push every word into array as TouchableView

like ViewsItem.push(<TouchableOpacity onPress={'run your function '}><Text> {'your name '}</Text></TouchableOpacity>)

and then after use text.map(item => {return item; })} inside return

Upvotes: 1

Related Questions