skip to Main Content

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?

3

Answers


  1. Chosen as BEST ANSWER

    Actually this one do the trick suppressHighlighting applied to the Text component


  2. 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>
    
    Login or Signup to reply.
  3. Try this:

    <Pressable style={({pressed})=>[styles.text, {backgroundColor: pressed ? 'white' : 'white' }]}>
       <Text> Click Me! </Text>
    </Pressable>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search