Sign in to Reactiive

Use your Google or Apple account.
Signing in subscribes you to the newsletter: new content and the occasional promotion. Unsubscribe at any time.
Skip to content

Verification Code Input with Reanimated

Wednesday, January 31, 2024
enzomanuelmangano
demos
verification-code
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A verification code input interface with validation and animations.

What's This About?

This component creates an interactive verification code input screen with validation and feedback animations. It features a customizable code length, validation against a correct code, and visual feedback for user input. The implementation includes digit input handling, validation logic, and animated transitions, making it perfect for authentication flows or any scenario requiring secure code verification.

Technical Implementation

The component uses:
Code validation
Input handling
Visual feedback
Animated transitions
State management

Usage

// Basic usage with correct code <VerificationCode correctCode={31415} /> // Verification code screen <VerificationCodeScreen correctCode={correctCode} onSuccess={() => { // Handle successful verification }} onError={() => { // Handle verification error }} /> // Code validation const validateCode = (input: string) => { return input === String(correctCode); }; // Input handling const handleCodeChange = (code: string) => { if (code.length === CODE_LENGTH) { const isValid = validateCode(code); if (isValid) { onSuccess?.(); } else { onError?.(); } } }; // Animated feedback const animatedStyle = useAnimatedStyle(() => ({ transform: [ { translateX: withSpring(isError.value ? 10 : 0, { damping: 3, stiffness: 100 }) } ] }));

Unlock the beauty of React Native animations

Learn Reanimated, Gesture Handler & Skia with Reanimate.dev

Feedback on Verification Code

Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback