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-next-input

v0.10.8

Published

React-native component which will automatically change focus to next input element making it great to use when making OTP screens, pin based login screens or even date of birth component

Downloads

30

Readme

React-Native-Next-Input

| | Status | | - | - | | Dependencies | Dependencies Dev dependencies Peer dependencies| | Package | npm package version npm downloads

Description

React-native component which will automatically change focus to next input element making it great to use when making OTP screens, pin based login screens or even date of birth component

Note: If you like the repo, please give it a star on github

Installation

npm install react-native-next-input --save

Usage

Import react-native-next input

import NextTextInput from 'react-native-next-input'

and then use it like this

<NextTextInput 
  noOfTextInput={4}
  textInputStyle={styles.textBox}
  onChangeValue={inputFromChildComponent}
  parentViewStyle={styles.textBoxes}
/>

where we are capturing the input from the child component in inputFromChildComponent like this

inputFromChildComponent = (combinedValueArray, currentValue, refForTheCurrentValue) => {
			console.log(combinedValueArray, currentValue,  refForTheCurrentValue)
	}

Clear Input

  1. Pass a boolean state set to false initally to NextTextInput
<NextTextInput 
  noOfTextInput={4}
  textInputStyle={styles.textBox}
  onChangeValue={inputFromChildComponent}
  parentViewStyle={styles.textBoxes}
  clear={invalid}
  isInputCleared={isInputCleared}
/>

You can change clear the input by changing the state to true


verifyOTP = () => {
	try {
		if (currentNumbersEntered.length === 4) {
			phoneInstance.verifyOtp(currentNumbersEntered )
		
			props.navigation.navigate('SucessAuth') // Assume this throws error and code goes to catch statement
		} else {
			// To display error
			dropDownAlertRef.alertWithType('error', 'Error', frontendErrors.OTP_LENGTH)
		}
	} catch (err) {
		// Since user entered invalid otp, we decide to clear text in input box
		setInvalid(true) // this will clear input  
	}
}

inputFromChildComponent = (combinedValueArray, currentValue, refForTheCurrentValue) => {
	if (clear) {
		// If you have cleared the state or passed true in clear props, it's recommended that you re-change it to false
		setClear(false)
	}
	console.log(combinedValueArray, currentValue,  refForTheCurrentValue)
}

Props

| Prop | Type | Default | Required | description | |----------|----------|-------------|--------------|--------------| | noOfTextInput | number | null | Yes | No of text input elements you want for example in case of otp screen it could be 4 text-input elements, In case of date of birth it could be 8 (DD-MM-YYYY) | | onChangeValue | function | null | Yes | the function to capture the input value entered by the user, this function recieves three parameters, the entire updated array holding entered value(s), the current value entered by user, and ref for the current value (see above example)| | placeholder | array | empty array | No | If in case you want to have a placeholder value for your input elements, for example in case of date of birth you might want TextInput to have dd-mm-yyyy (pass an array for placeholder like this: ['D', 'D', 'M', 'M', 'Y', 'Y', 'Y', 'Y']) | | displayColum | boolean | false | No | By default orientation of text input element is keept to be false, meaning the Text input would have flexDirection: row, by setting true, you will change the flexDirection to column | | keyboardType | String | numeric | No | Since, this parameter is being passed to <TextInput, it supports all the values as mentioned in react-native documentation for TextInput, by default the value is set to numeric | | textInputStyle | object | null | No | Styling for your the mapped-input element (the above style of boxes in case of the otp screen) | | parentViewStyle | object | null | no | the styling for the parent view under which the input elements are mapped | | value | Array | null | No | Array containing default values/or values user might have previously entered in the forn | | clear | Boolean | false | No | When true it will clear everything in the input boxes and change focus to first box | | isInputCleared | function | null | no | this function emits value to parent function passed once the state is cleared |

Examples

  1. Example of Date Picker Component
  2. Example of OTP Component