1.2.2 • Published 5 years ago
react-native-cross-prompt v1.2.2
react-native-cross-prompt
A cross-platform, Google/Android & iOS style, Component for React-Native apps to prompt for user input.
NPM
https://www.npmjs.com/package/react-native-cross-prompt
Installation
$ npm install react-native-cross-prompt --save
Demo
Android
iOS
Pending..
Usage
import Prompt from 'react-native-cross-prompt'
constructor(props) {
super(props);
this.state = {
promptVisible: false,
}
}
_handlePrompt = (value) => {
alert(value)
}
<View>
<Text>Tap the button to show the prompt!</Text>
<Button
title="Press me!"
onPress={() => this.setState({ promptVisible: true })}
/>
<Prompt
visible={this.state.promptVisible}
title="Title"
description="This is the prompt description."
placeholder="placeholder"
onCancel={(visible) => this.setState({ promptVisible: visible })}
onSubmit={(value) => this._handlePrompt(value)}
/>
</View>
API
props:
visible
(boolean) -- Prompt is visible whentrue
title
(string, required) -- Set the title of the promptdescription
(string, required) -- Set the description of the promptplaceholder
(string, required) -- Set the placeholder of the input field in the promptvalue
(string) -- Set the initial value of the input field in the promptonCancel
(function, required) -- Function that is called when "CANCEL" was firedonSubmit
(function, required) -- Function that is called when "OK" was fired
Testing
Install node modules
npm install
Run
npm test