# react-native-alert-async

> An Alert.alert() that you can await

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

## Install

```sh
npm install react-native-alert-async
pnpm add react-native-alert-async
yarn add react-native-alert-async
bun add react-native-alert-async
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2020-01-03 |
| First published | 2018-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Sébastien Lorber |
| Maintainers | slorber |
| Keywords | react, react-native, reactnative, alert, async, await |

## Links

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

## 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.5 (latest) — 2020-01-03
- 1.0.4 — 2020-01-03
- 1.0.3 — 2018-11-19
- 1.0.2 — 2018-11-19
- 1.0.1 — 2018-11-19
- 1.0.0 — 2018-11-19

## README

# react-native-alert-async

An Alert.alert() that you can await 

```jsx
import AlertAsync from "react-native-alert-async";

const myAction = async () => {

  const choice = await AlertAsync(
    'Title',
    'Message',
    [
      {text: 'Yes', onPress: () => 'yes'},
      {text: 'No', onPress: () => Promise.resolve('no')},
    ],
    {
      cancelable: true,
      onDismiss: () => 'no',
    },
  );

  if (choice === 'yes') {
    await doSomething();
  }
  else {
    await doSomethingElse();
  }
}
```

It always returns a promise, and that promise is guaranteed to resolve after the user made his choice.

It's just a wrapper around the original RN API so it's very tiny and does not require native code/linking, and is compatible with Expo.


There is an existing [RN PR](https://github.com/facebook/react-native/pull/20312) waiting to be merged with this feature. In the meantime you can use this package.
I use this in production for a long time and it's reliable.

# Hire a freelance expert

Looking for a React/ReactNative freelance expert with more than 5 years production experience?
Contact me from my [website](https://sebastienlorber.com/) or with [Twitter](https://twitter.com/sebastienlorber).

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