NaDa Bayomy
NaDa Bayomy

Reputation: 31

react-native get selection text start and end from text component

I used Text component reference: https://facebook.github.io/react-native/docs/text.html

with property selectable={true}, is there any solution to get the user text selection start and end on Text component not TextInput component?

because I need to make the text selectable with editable false.

Upvotes: 3

Views: 1255

Answers (1)

fakenickels
fakenickels

Reputation: 171

You can use this https://github.com/Astrocoders/react-native-selectable-text/

import { SelectableText } from "react-native-selectable-text";

// Use normally, it is a drop-in replacement for react-native/Text
<SelectableText
  menuItems={["Foo", "Bar"]}
  onSelection={({ eventType, content, selectionStart, selectionEnd }) => {}}
  value="I crave star damage"
/>;

Upvotes: 1

Related Questions