# @nghinv/react-native-loading

> React native loading screen

Latest version **1.0.3** (published 2021-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nghinv/react-native-loading
pnpm add @nghinv/react-native-loading
yarn add @nghinv/react-native-loading
bun add @nghinv/react-native-loading
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-02-19 |
| First published | 2020-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | nghinv@lumi.biz |
| Maintainers | nghinv |
| Keywords | react-native, loading, react-native-loading, react native loading, spinner, overlay, @nghinv/react-native-loading, @nghinv, nghinv, lumi, lumi-software |

## Links

- npm: https://www.npmjs.com/package/@nghinv/react-native-loading
- Repository: https://github.com/nghinv-software/react-native-loading
- Homepage: https://github.com/nghinv-software/react-native-loading#readme
- Issues: https://github.com/nghinv-software/react-native-loading/issues
- npm.io page: https://npm.io/package/@nghinv/react-native-loading

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [post-robot](https://npm.io/package/post-robot.md) — 93.7K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-02-19
- 1.0.2 — 2020-06-12
- 1.0.1 — 2020-06-11
- 1.0.0 — 2020-06-11

## README

# @nghinv/react-native-loading

Loading an overlay when running long tasks in the react-native application.

# Installation

## Installing the package

* Use yarn

```sh
yarn add @nghinv/react-native-loading
```

* Use npm

```sh
npm install @nghinv/react-native-loading
```

<img src="./assets/example.gif" height="600"/>

# How to use

1. Wrapper `LoadingService` in the `Root Component`

```javascript
  ...
  return (
    <LoadingService>
      <RootComponent />
    </LoadingService>
  );
  ...
```

2. Use `Spinner.show()` and `Spinner.hide()`

```javascript
import React from 'react';
import { View, StyleSheet, Button } from 'react-native';
import { Spinner, LoadingService, LoadingView } from '@nghinv/react-native-loading';

export default function Example() {
  const onPress = () => {
    Spinner.show();
    setTimeout(() => {
      Spinner.hide();
    }, 2000);
  };

  return (
    <LoadingService>
      <View style={styles.container}>
        <Button title='Show loading' onPress={onPress} />
      </View>
    </LoadingService>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'skyblue'
  }
});
```

- Show loading with custom property

```javascript
  ...
  onShow = () => {
    Spinner.show({ indicatorColor: 'red' });
  }
  ...
```

# Property


## LoadingView property

| Property | Type | Default | Description |
|----------|:----:|:-------:|-------------|
| visible | `Bool` | `false` | show/hide loading |
| indicatorColor | `String` | `white` | |
| indicatorSize | `large/small` | `large` | |
| backgroundColor | `String` | `rgba(0, 0, 0, 0.4)` | |
| renderIndicator | `func` | `undefined` | Custom loading component |
| containerStyle | `ViewStyle` |  | |


## LoadingService property

| Property | Type | Default | Description |
|----------|:----:|:-------:|-------------|
| defaultProps | `LoadingViewProperty` | | |


## Spinner property

| Property | Type | Default | Description |
|----------|:----:|:-------:|-------------|
| show | `(params: LoadingViewProperty) => void` | | show loading when call |
| hide | `func` | | hide loading when call |

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