import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { Text, TextInput, View } from 'react-native'; import styles from '../Profile.styles.js'; const STRINGS = { HINT: `Password must be at least 8 characters and contain a minimum of one lowercase and one uppercase letter, a number, and a symbol. Spaces are allowed. Be memorable and secure!`, MATCH: `That's a match!`, NO_MATCH: `Well that's not a match...`, PLACEHOLDER_PASSWORD: 'password', PLACEHOLDER_VERIFY: 're-enter password', }; export default function PasswordInput({ handleValidPasswordEntry }) { const [password, setPassword] = useState(null); const [doPasswordsMatch, setPasswordMatch] = useState(null); const _doesVerificationPasswordMatch = (text) => { if (!password || password.length < text.length) { setPasswordMatch(null); return; } const result = password === text; handleValidPasswordEntry(result && password); setPasswordMatch(result); }; return ( {STRINGS.HINT} {doPasswordsMatch === true && {STRINGS.MATCH}} {doPasswordsMatch === false && {STRINGS.NO_MATCH}} ); } PasswordInput.propTypes = { handleValidPasswordEntry: PropTypes.func.isRequired, };