# react-native-odometer

> Odometer for React Native

Latest version **1.0.4** (published 2020-05-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-odometer
pnpm add react-native-odometer
yarn add react-native-odometer
bun add react-native-odometer
```

## 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.4 |
| Published | 2020-05-25 |
| First published | 2020-05-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 15.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Akshat Mittal |
| Maintainers | akshatmittal |
| Keywords | react-native, odometer, react, ticker, animated |

## Links

- npm: https://www.npmjs.com/package/react-native-odometer
- Repository: https://github.com/akshatmittal/react-native-odometer
- Homepage: https://github.com/akshatmittal/react-native-odometer#readme
- Issues: https://github.com/akshatmittal/react-native-odometer/issues
- npm.io page: https://npm.io/package/react-native-odometer

## Dependencies (2)

- [react-native-reanimated](https://npm.io/package/react-native-reanimated.md) ^1.4.0
- [number-to-locale-string-polyfill](https://npm.io/package/number-to-locale-string-polyfill.md) ^1.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2020-05-25
- 1.0.2 — 2020-05-23

## README

# React Native Odometer

Odometer for React Native, supports numbers, localization and strings.

# Features

- Animations with `react-native-reanimated`.
- Custom animation duration via `duration` prop.
- Automatically measures all widths and heights of items and adjusts accordingly.
- Supply a `children` element with the number or string.
- Numbers can be formatted to custom locale via `locale` prop.
- Uses `tabular-nums` fontVariant to avoid layout shifting.

# Install

```
npm i react-native-odometer
```

If your React runtime does not support Intl but you want to use number localization, also install the polyfill or switch runtime.

```
npm i number-to-locale-string-polyfill
```

# Example

```jsx
import Odometer from "react-native-odometer";
```

## Simple Odometer

```jsx
<Odometer>12345.44</Odometer>
```

## Odometer with Localization

```jsx
<Odometer locale="en-IN">12345.44</Odometer>
```

## Custom Odometer

```jsx
const currencies = ["$", "₹", "€"];

const App = () => {
  const [state, setState] = useState({
      currency: currencies[0],
      value: 0
    });

  useEffect(() => {
    setInterval(() => {
      setState({
        currency: currencies[Math.floor(Math.random() * 3)],
        value: Math.floor(Math.random() * 1000000)
      });
    }, 500);
  }, []);

  return (
    <View>
      <Odometer>
        <Odometer.Fragment rotateItems={currencies}>{state.currency}</Odometer.Fragment>
        {state.value}
      </Odometer>
    </View>
  );
};
```
# Props

| Prop          	| Required 	| Default 	| Description                                                     	|
|---------------	|----------	|---------	|-----------------------------------------------------------------	|
| `children`    	| Yes      	| -       	| The Odometer number/text to render.                             	|
| `duration`    	| No       	| 500ms   	| Animation Duration                                              	|
| `textStyle`   	| No       	| -       	| Additional Styling for Text                                     	|
| `textProps`   	| No       	| -       	| Additional Props for Text                                       	|
| `rotateItems` 	| No       	| -       	| Only for Fragment. Possible characters for Odometer custom.     	|
| `locale`      	| No       	| ""      	| Localization identifier for numbers. Eg: "en-US", "en", "en-IN" 	|

## Thanks

React Native Odometer is based on `react-native-ticker`.

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