react-native-read-more-text
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/react-native-read-more-text package

1.1.2 • Public • Published

react-native-read-more-text

Installation

npm i react-native-read-more-text --save

or with yarn

yarn add react-native-read-more-text

Props

Prop Type Required Note
onReady function no callback function to know when the component is ready
children string yes String to render on read more component
renderTruncatedFooter function no function that will replace the Read more label
renderRevealedFooter function no function that will replace the Hide label

Try it on Expo

Example

Usage

 
import * as React from 'react';
import { View, Text } from 'react-native';
import ReadMore from 'react-native-read-more-text';
 
export class DescriptionCard extends React.Component {
  render() {
    let { text } = this.props;
 
    return (
      <View>
        <View style={styles.cardLabel}>
          <Text style={styles.cardLabelText}>
            Description
          </Text>
        </View>
 
        <View style={styles.card}>
          <View style={styles.cardBody}>
            <ReadMore
              numberOfLines={3}
              renderTruncatedFooter={this._renderTruncatedFooter}
              renderRevealedFooter={this._renderRevealedFooter}
              onReady={this._handleTextReady}>
              <Text style={styles.cardText}>
                {text}
              </Text>
            </ReadMore>
          </View>
        </View>
      </View>
    );
  }
 
  _renderTruncatedFooter = (handlePress) => {
    return (
      <Text style={{color: Colors.tintColor, marginTop: 5}} onPress={handlePress}>
        Read more
      </Text>
    );
  }
 
  _renderRevealedFooter = (handlePress) => {
    return (
      <Text style={{color: Colors.tintColor, marginTop: 5}} onPress={handlePress}>
        Show less
      </Text>
    );
  }
 
  _handleTextReady = () => {
    // ...
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-read-more-text

Weekly Downloads

4,460

Version

1.1.2

License

MIT

Unpacked Size

5.17 kB

Total Files

3

Last publish

Collaborators

  • brentvatne
  • eriveltonelias