### Running the Example Project for react-native-more-or-less-text Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/README.md Provides instructions to clone the project repository, install dependencies, and run the example application on both iOS and Android platforms. This is useful for testing and understanding the component's behavior. ```sh git clone https://github.com/rarenatoe/react-native-more-or-less-text.git cd more-or-less/example yarn install # or npm install # to run on iOS yarn ios #to run on android yarn android ``` -------------------------------- ### Start Metro Server for Example App Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/CONTRIBUTING.md Starts the Metro bundler, which is essential for running the example application. Changes to the library's JavaScript code will be reflected in the app without a rebuild. ```shell yarn example start ``` -------------------------------- ### Run Example App on Web Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/CONTRIBUTING.md Builds and runs the example application in a web browser. This command is used to test changes made to the library on the web platform. ```shell yarn example web ``` -------------------------------- ### Run Example App on iOS Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/CONTRIBUTING.md Builds and runs the example application on an iOS simulator or device. This command is used to test changes made to the library on the iOS platform. ```shell yarn example ios ``` -------------------------------- ### Run Example App on Android Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/CONTRIBUTING.md Builds and runs the example application on an Android device or emulator. This command is used to test changes made to the library on the Android platform. ```shell yarn example android ``` -------------------------------- ### Install Project Dependencies with Yarn Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/CONTRIBUTING.md Installs all necessary project dependencies using Yarn. This is the first step to setting up the development environment for the project. It's recommended to use Yarn for development as the tooling is built around it. ```shell yarn ``` -------------------------------- ### Install react-native-more-or-less-text using npm or yarn Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/README.md Instructions for installing the library using various package managers including npm, yarn, pnpm, and bun. This is the first step to using the component in your React Native project. ```sh npm install react-native-more-or-less-text ``` ```sh yarn add react-native-more-or-less-text ``` ```sh pnpm add react-native-more-or-less-text ``` ```sh bun add react-native-more-or-less-text ``` -------------------------------- ### Bootstrap Project Dependencies and Pods Source: https://github.com/rarenatoe/react-native-more-or-less-text/blob/main/CONTRIBUTING.md Initializes the project by installing all dependencies and CocoaPods for iOS. This script ensures the project is set up correctly for development. ```shell yarn bootstrap ``` -------------------------------- ### React Native MoreOrLess Component Props and Example Source: https://context7.com/rarenatoe/react-native-more-or-less-text/llms.txt Defines the TypeScript types for MoreOrLessProps and demonstrates a full configuration example for the component. This includes setting the number of lines, various styles for the container, text, and button, custom text components, custom 'more'/'less' text, animation, and ellipsize mode. It requires 'react-native-more-or-less-text' and 'react-native' as dependencies. ```tsx import { MoreOrLess } from 'react-native-more-or-less-text'; import { Text } from 'react-native'; type MoreOrLessProps = { children: string; // Required: Text content to display numberOfLines: number; // Required: Max lines when collapsed containerStyle?: ViewStyle; // Optional: Container view styling textStyle?: TextStyle; // Optional: Base text styling textButtonStyle?: TextStyle; // Optional: Button text styling textComponent?: ComponentType; // Optional: Custom text component moreText?: string; // Optional: Default 'more' lessText?: string; // Optional: Default 'less' animated?: boolean; // Optional: Default false onMorePress?: () => void; // Optional: Custom more handler ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip'; // Optional: Ellipsize mode }; // Full configuration example Your text content here ``` -------------------------------- ### Dynamic Content Updates with MoreOrLess Source: https://context7.com/rarenatoe/react-native-more-or-less-text/llms.txt Shows how to handle dynamic content changes in the MoreOrLess component by managing state and using a key prop to force re-renders. This example cycles through different articles, demonstrating re-rendering with new content. It requires React, useState, Button, StyleSheet, and MoreOrLess. ```tsx import React, { useState } from 'react'; import { View, Button, StyleSheet } from 'react-native'; import { MoreOrLess } from 'react-native-more-or-less-text'; const articles = [ 'First article content with multiple paragraphs...', 'Second article with different length and content...', 'Third article that might be shorter or longer...' ]; export default function DynamicContent() { const [currentIndex, setCurrentIndex] = useState(0); const nextArticle = () => { setCurrentIndex((prev) => (prev + 1) % articles.length); }; return ( {articles[currentIndex]}