Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-sms-verifycode

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-sms-verifycode

A component for entering a set of SMS verification codes for react-native, Compatible for Android and iOS

  • 2.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

中文版

Screen Capture

Support for entering passwords, compatible with iOS and Android

androidiOSPassword
on Androidon iOSuse Password

The design idea is probably like this, showing an excellent hand drawing 🙈 🙈 🙈

design

Installation

$ npm install react-native-sms-verifycode --save

Usage

Basic Usage

Set the callback function when the input is complete, you can get the content input by the user.

import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  ref={ref => (this.verifycode = ref)}
  onInputCompleted={this.onInputCompleted}
  containerPaddingHorizontal={30}
/>

onInputCompleted = (text) => {
	Alert.alert(
	  text,
	  '本次输入的验证码',
	  [
	  	{
	      text: '确定',
	    },
	  ]
	)
}

reset = () => {
	this.verifycode.reset()
	this.setState({codeText: ''})
}
...        
androidiOSall

Advanced Usage

Set the length of the verification code
import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={4} // Set any number as needed, type must be number
/>
androidiOSiOS
Set Container's style
import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={5}
  containerPaddingVertical={10}
  containerPaddingHorizontal={50}
  containerBackgroundColor={'#8DC647'}
/>
...        
androidandroidiOS
Set code view style
import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={6}
  containerPaddingVertical={10}
  containerPaddingHorizontal={50}
  containerBackgroundColor="#8DC647"
  codeViewBorderColor="#000000"
  focusedCodeViewBorderColor="#0000FF"
  codeViewBorderWidth={3}
  codeViewBorderRadius={16}
/>
...        
androidiOSiOS
Set code style
import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={5}
  codeFontSize={26}
  // codeColor={'#89C047'}
/>
...        
androidiOSiOS

Properties

PropPropTypeDefault ValueisRequiredDescription
autoFocusboolfalseNOWhether to automatically get the focus by default
verifyCodeLengthnumber6NOlength of the verification code
initialCodesarray6NOThe default is empty, if set, it will be automatically populated
containerStyleobjectnullNOset container style
containerPaddingVerticalnumber0NOcontainer's paddingVertical
containerPaddingLeftnumber0NOset container paddingLeft
containerPaddingRightnumber0NOset container paddingRight
containerPaddingHorizontalnumberAutomatic calculation based on the length of the verification codeNOcontainer's paddingHorizontal
containerPaddingLeftnumber0NOset container paddingLeft
containerPaddingRightnumber0NOset container paddingRight
containerBackgroundColorstring#FDFFFDNOcontainer's backgroundColor
codeViewStyleobjectnullNOset code view style
codeViewWidthnumberAutomatic calculation based on the length of the verification codeNOwidth of code view
codeViewBorderColorstringgreyNOcolor of code view border
focusedCodeViewBorderColorstring#1192F6NOThe color of the currently focused text box
codeViewBorderWidthnumber1NOwidth of code view border
codeViewBorderRadiusnumber5NOradius of code view border
codeViewBackgroundColorstringdefaultNOcode view background color
codeFontSizenumberdefaultNOcode font size
codeColorstring#222222NOcolor of code
secureTextEntrybooleanfalseNOSet to true when entering a password,default is false
coverStyleobjectnullNOcover style
coverRadiusnumbercodeFontSize / 2NOcover radius
coverColorstringblackNOcover color
warningTitlestringblackNOWhen the input content is not a number, the title of the prompt box
warningContentstringblackNOWhen the input content is not a number, the content of the prompt box
warningButtonTextstringblackNOWhen the input content is not a number, the button text of the prompt box

APIs

NameisRequiredDescription
onInputChangeTextNOWhen the text in the input box changes, the method is called, and the latest value is returned.
onInputCompletedNOCallback method when input is complete
resetNOClear the input and set the focus to the first input box, call using ref
blurNOHide the keyboard, call using ref
focusNODisplay keyboard, call using ref

Keywords

FAQs

Package last updated on 22 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc