Code Monkey home page Code Monkey logo

react-native-prompt's Introduction

react-native-prompt

A cross-platform prompt component for React Native.

Installation

$ npm install react-native-prompt --save

Demo

iOS Android

Basic Usage

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.

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.

Testing

Install dev modules:

npm install

Run tests

npm test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.