# react-native-prompt

> A cross-platform prompt component for React Native.

Latest version **1.0.0** (published 2016-11-18) · ISC license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2016-11-18 |
| First published | 2016-01-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 173 |
| Author | Jack Hsu |
| Maintainers | jaysoo |
| Keywords | react-native, react, prompt, spinner, dropdown, react-component, ios, android |

## Links

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

## 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.0 (latest) — 2016-11-18
- 0.18.5 — 2016-06-17
- 0.18.4 — 2016-05-10
- 0.18.3 — 2016-02-04
- 0.18.2 — 2016-02-04
- 0.18.1 — 2016-02-04
- 0.18.0 — 2016-01-29

## README

[![](https://img.shields.io/npm/dm/react-native-prompt.svg?style=flat-square)](https://www.npmjs.com/package/react-native-prompt)

# react-native-prompt

A cross-platform prompt component for React Native.

## Installation

```
$ npm install react-native-prompt --save
```

## Demo

| iOS | Android |
| --- | ------- |
| ![](./demo.ios.gif) | ![](./demo.android.gif) |

## Basic Usage

```js
import Prompt from 'react-native-prompt';

// Inside render()
<Prompt
    title="Say something"
    placeholder="Start typing"
    defaultValue="Hello"
    visible={ this.state.promptVisible }
    onCancel={ () => this.setState({
      promptVisible: false,
      message: "You cancelled"
    }) }
    onSubmit={ (value) => this.setState({
      promptVisible: false,
      message: `You said "${value}"`
    }) }/>
```

Please refer to the full working example [here](./PromptExample/PromptExample.js).

## API

Props:

- `visible` (boolean) -- When `true`, the prompt is displayed, closes otherwise
- `title` (string, required) -- The title text of the prompt
- `placeholder` (string) -- The placeholder text of the prompt
- `defaultValue` (string) -- The default value of the prompt
- `onCancel` (function, required) -- Function that is called when user cancels prompt
- `onSubmit` (function, required) -- Function that is called with user's value when they submit
- `submitText` (string) -- The string that is displayed on the submit button (defaults to "OK")
- `cancelText` (string) -- The string that is displayed on the cancel button (defaults to "Cancel")
- `onChangeText` (function) -- Function that is called with user input when it changes.
- `textInputProps` (Object) -- Additional props on the input element

## Testing

Install dev modules:

```
npm install
```

### Run tests

```
npm test
```

## Changelog

### 1.0.0

- Updates `value` when `defaultValue` changes. (Thanks https://github.com/vessp)
- Removes unnecessary `flex: 1` style. (Thanks https://github.com/stevehollaar)

### 0.18.6

- Adds `textInputProps` to allow additional props to be passed to the input element. Thanks @yueshuaijie!

### 0.18.5 

- Fixed compatibility with React Native 0.27.2 (thanks [@sibelius](https://github.com/sibelius) and [@tonyxiao](https://github.com/tonyxiao)!)

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