/* eslint-disable react-hooks/exhaustive-deps */ /* eslint-disable react-native/no-inline-styles */ import React, { memo, useEffect } from 'react'; import { Text, View } from 'react-native'; var zxcvbn = require('zxcvbn'); import { strengthLabel } from './../utils/password-meter.utils'; import ProgressBar from 'react-native-animated-progress'; import type { meter } from 'src/interface/meter.interface'; const PasswordMeter = ({ password, onResult }: meter) => { const { feedback, score } = zxcvbn(password); const { suggestions, warning } = feedback; useEffect(() => { onResult(score); }, [score]); // onResult(score); return ( {password.length > 0 ? ( {strengthLabel(score).text} {warning.length > 0 || suggestions.length > 0 ? ( {warning.length > 0 && ( {warning} )} {suggestions.length > 0 && ( {suggestions.map((text: any, key: any) => { return ( {key + 1}. {text} ); })} )} ) : ( )} ) : ( )} ); }; export default memo(PasswordMeter);