skip to Main Content

suppose there is lots of text in text tag of react native , then i want to add a button at the end of this text ( more ).

<View style={styles.container}>
  {" "}
  <Text style={styles.paragraph}>
    {" "}
    Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    Lorem Ipsum has been the industry's standard dummy text ever since the
    1500s, when an unknown printer took a galley of type and scrambled it to
    make a type specimen book. It has survived not only five centuries, but also
    the leap into electronic typesetting, remaining essentially unchanged. It
    was popularised in the 1960s with the release of Letras{" "}
  </Text>{" "}
  <Pressable>
    {" "}
    <Text>more</Text>{" "}
  </Pressable>{" "}
</View>;

I can use pressable but it is a block element , i want it be inline. so that text and button can stay together.

2

Answers


  1. You can use react-native-read-more library instead of doing on your own. However, if you want to learn how to do it. I strongly suggest that go to this library and read how it should have done it 🙂

    Login or Signup to reply.
  2. Wrap all Text and Pressable components with one top level Text component and everything is inlined.

    <Text>
      <Text>
    ...
      </Text>
      <Pressable>
        <Text>more</Text>
      </Pressable>
      <Text>
    ...
      </Text>
    </Text>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search