# text-provider-react-native

> A component which provides all the string constants using provider pattern.

Latest version **1.0.5** (published 2020-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install text-provider-react-native
pnpm add text-provider-react-native
yarn add text-provider-react-native
bun add text-provider-react-native
```

## 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 | 2020-03-21 |
| First published | 2019-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 59.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rohith R |
| Maintainers | rohithr31 |

## Links

- npm: https://www.npmjs.com/package/text-provider-react-native
- npm.io page: https://npm.io/package/text-provider-react-native

## Dependencies (1)

- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Recent versions

- 1.0.5 (latest) — 2020-03-21
- 1.0.4 — 2020-01-27
- 1.0.3 — 2020-01-26
- 1.0.2 — 2019-07-15
- 1.0.1 — 2019-07-12
- 1.0.0 — 2019-07-12

## README

<div align="center">
    <img
        width="200" height="200"
        src="./logo.png"
    />
    <h1>text-provider-react-native</h1>
    <p>
        A react-native component which provides all the string constants using provider pattern
    </p>
</div>

<div align="center">
    <a href="https://circleci.com/gh/intuit/text-provider-react-native">
        <img
            src="https://img.shields.io/circleci/project/github/intuit/text-provider-react-native/master.svg?style=flat-square&logo=circleci"
            alt="CircleCI"
        />
    </a>
    <a href="https://www.npmjs.com/package/text-provider-react-native">
        <img
            src="https://img.shields.io/npm/v/text-provider-react-native.svg?style=flat-square&logo=npm"
            alt="npm"
        />
    </a>
    <a href="https://github.com/intuit/text-provider-react-native/graphs/contributors">
        <img
            src="https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square&logo=github"
            alt="All Contributors"
        />
    </a>
    <a href="https://www.npmjs.com/package/text-provider-react-native">
        <img
            src="https://img.shields.io/npm/dt/text-provider-react-native.svg?style=flat-square&logo=npm"
            alt="npm"
        />
    </a>
</div>


It provides two components:

1. [TextProvider](src/TextProvider/index.js)
2. [FormattedMessage](src/FormattedMessage/index.js)

## Install

```bash
npm i text-provider-react-native
```

## Usage

1. Import the string constants required for the particular presentational component:

```javascript
const sampleText = require("src/nls/sample-text.json");
```

2. Use the [TextProvider](src/TextProvider/index.js) to make it available for all the components:

```jsx
<TextProvider globalText={sampleText} >
  <MyPresentationalComponent />
</TextProvider>
```

3. Use it inside the presentational component:

```jsx
<FormattedMessage id="Random Id"/>
```

```jsx
const randomId = "Random Id";
const values = {
  "valueToBeInjected": "Random Value"
};

<FormattedMessage id={randomId} values={values}/>
```

Works like a format string also. Example JSON:

```json
{
  "Random Id": "<b>Random Text Returns</b> {valueToBeInjected} for each text)"
}
```

Then ``${valueToBeInjected}`` gets replaced with the value specified in `values`.

Make sure that a string by the same `id` exists in the JSON file.

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