# react-native-read-more-text-hooks

> Add a 'Read More' and optionally a 'Read Less' button to text that exceeds a given number of lines

Latest version **1.0.5** (published 2019-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-read-more-text-hooks
pnpm add react-native-read-more-text-hooks
yarn add react-native-read-more-text-hooks
bun add react-native-read-more-text-hooks
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2019-12-06 |
| First published | 2019-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Alex Stoimenov |
| Maintainers | astoimenov |

## Links

- npm: https://www.npmjs.com/package/react-native-read-more-text-hooks
- Repository: https://github.com/astoimenov/react-native-read-more-text-hooks
- Homepage: https://github.com/astoimenov/react-native-read-more-text-hooks#readme
- Issues: https://github.com/astoimenov/react-native-read-more-text-hooks/issues
- npm.io page: https://npm.io/package/react-native-read-more-text-hooks

## Recent versions

- 1.0.5 (latest) — 2019-12-06
- 1.0.4 — 2019-12-06
- 1.0.3 — 2019-12-06
- 1.0.2 — 2019-12-06
- 1.0.1 — 2019-12-06
- 1.0.0 — 2019-12-06

## README

# react-native-read-more-text-hooks
React Native component to add a 'Read More' and optionally a 'Read Less' button to text that exceeds a given number of lines. Written with React Hooks ;)

### Installation

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

or

```
yarn add react-native-read-more-text-hooks
```

### Usage

```javascript
import React from "react";
import { Text, View } from "react-native";
import ReadMore from "react-native-read-more-text-hooks";

const _renderTruncatedFooter = (handlePress: () => void) => {
  return (
    <Text style={{ marginTop: 5 }} onPress={handlePress}>
      Read more
    </Text>
  );
};

const _renderRevealedFooter = (handlePress: () => void) => {
  return (
    <Text style={{ marginTop: 5 }} onPress={handlePress}>
      Show less
    </Text>
  );
};

const _handleTextReady = () => {
  // ...
};

const DescriptionCard = ({ text }: { text: string }) => (
  <View>
    <Text>Description</Text>

    <ReadMore
      numberOfLines={3}
      renderTruncatedFooter={_renderTruncatedFooter}
      renderRevealedFooter={_renderRevealedFooter}
      onReady={_handleTextReady}
    >
      <Text>{text}</Text>
    </ReadMore>
  </View>
);

export default DescriptionCard;
```

---
_Source: https://npm.io/package/react-native-read-more-text-hooks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
