npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-prompt-async

v1.0.17

Published

Package async similar to the JavaScript 'prompt' method, it's called in a single line with await

Downloads

19

Readme

react-native-prompt-async

https://www.npmjs.com/package/react-native-prompt-async

Package async similar to the JavaScript 'prompt' method, it's called in a single line with await

Imagen 0

Table of Contents

Installation

npm i react-native-prompt-async

or

yarn add react-native-prompt-async

After installation, you must import InitializePrompt and include it in the main root file of your app, usually "App.js".

import { View } from "react-native";
import { initializePrompt } from "react-native-prompt-async";

export default function App (){

  return (
    <View>
      <InitializePrompt/>
      {/* your code */}
    </View>
  );
}

Usage

You can pass just a string by referencing the title property of the prompt or you can pass an object with the properties

import react from 'react';
import { View, Text, Pressable } from "react-native";
import prompt from 'react-native-prompt-async';

function App() {

  async function action (){
    const response = await prompt("¿question?");
    // your code
  }

  return (
    <View>
      <Pressable onPress={action} >
        <Text>Button</Text>
      </Pressable>
    </View>
  );
}

passing properties to the object as parameters

async function action (){
  const response = await prompt({
    title: "¿Why are you a programmer??", 
	  description: "hello:)"
  });
  // your code
}

Response

prompt returns only 3 types of data, false, true or string.

false will be returned only if the user presses the button associated to the cancelButton property or also if he presses the overlay component (gray background) as long as the isOverlayClose property is true.

string will only be returned if the user presses the button that is not associated to the cancelButton property as long as the text field is not empty.

true will only be returned if the alert property is true and the user presses the button that is not associated to the cancelButton property.

Props

All props are optional

Prop | Type | Default | Description ----------------- | -------- | ----------- | ----------- title | string | "" | Title of prompt (Main word). description | string | "" | Prompt description, text that goes between the title and the text field. placeholder | string | "Enter the required.." | placeholder of TextInput. placeholderTextColor | string | "#DADADA" | placeholderTextColor of TextInput. textInputDefaultValue | string | "" | defaultValue of TextInput. autofocus | bool | true | Sets the autofocus property of the prompt's TextInput. if true as soon as the prompt window opens the keyboard will be activated automatically. cancelButton | string | "left" | Property that receives "left" or "right". Property that assigns as "close or cancel button" to any of the two buttons. if cancelButton is "left" then the left Button is going to be the close or cancel Button. leftButtonText | string | "Cancel" | Text to be displayed on the left button. rightButtonText | string | "Done" | Text to be displayed on the right button. leftButtonTextColor | string | "#D22929" | Text color displayed on the left button. rightButtonTextColor | string | "#76C856" | Text color displayed on the right Button. isOverlayClose | bool | false | Establishes whether the overlay (gray background) when pressed closes or cancels the prompt, if false it will not do so. keyboardSpace | number | 0 | Space between keyboard and prompt window, range 1-500. alert | bool | false | if true: sets the prompt to alert. button not associated with cancelButton returns true. buttonHidden | bool | none | hides either or both buttons. receives "left", "right" or "all" as a value. if "all" hides all buttons. if "left" or "right" hides the corresponding button.

This is how it looks by default: Imagen 1

This is how it looks like applying the description property with the value "hello:)": Imagen 2

This is how it looks like applying the placeholderTextColor property with the value "blue": Imagen 3

This is how it looks like applying the darkMode property with the value true and the keyboardSpace property with the value 50: Imagen 4

This is how it looks like applying the cancelButton property with the value "right": GIF 1