Home > OS >  Prevent text from selecting in react-naitve
Prevent text from selecting in react-naitve

Time:12-01

Code looks like this:

<Pressable>
  <Text>Click me</Text>
</Pressable>

When pressable is clicked, background color of text is changing, how to prevent it in react-native from changing?

CodePudding user response:

Background color doesn't change by default when pressable is clicked. But if you are facing this issue just give background color to Pressable none

<Pressable style={{backgroundColor: "none" }}>
  <Text>Click me</Text>
</Pressable>

CodePudding user response:

Try this:

<Pressable style={({pressed})=>[styles.text, {backgroundColor: pressed ? 'white' : 'white' }]}>
   <Text> Click Me! </Text>
</Pressable>
  • Related