import React, { FC, useState } from 'react'; import { TextInput, Text, View, InputModeOptions, NativeSyntheticEvent, TextInputFocusEventData } from 'react-native'; import { styling } from './style'; type Props = { placeholder?: string; onChange?: (text: string) => void; header?: string; isPrivate?: boolean; inputMode?: InputModeOptions; isFocused?: (boolean: boolean) => void; value?: string; active?: boolean; onBlur?: (e: NativeSyntheticEvent) => void; formikError?: string | boolean; }; export const Input: FC = ({ onChange, placeholder, header, isPrivate, inputMode, isFocused, onBlur, value, formikError }) => { const [focused, setFocused] = useState(false); const styles = styling(focused); return ( {header ? {header} : null} { setFocused(true); if (isFocused) { isFocused(true); } }} onBlur={(e) => { setFocused(false); if (onBlur) { onBlur(e); } }} style={[styles.wrapper, formikError ? styles.inputError : null]} /> {formikError ? {formikError} : null} ); };