import {Text, TextInput, View} from 'react-native'; import {styles, TextTheme} from '../common/styles'; import {useState} from 'react'; import {Section} from '../common/Section'; interface AddressForm { address_line_1?: string; city?: string; state_province?: string; postal_code?: string; country_code?: string; } interface AddressFormProps { nestedFormCallback: (tag: string, form: Object) => void; initForm: {[key: string]: any}; } const ADDRESS_KEY = 'Address'; export const AddressForm: React.FC = ({ nestedFormCallback, initForm, }) => { const [form, setForm] = useState(initForm[ADDRESS_KEY] || {}); const handleTextChange = (tag: keyof AddressForm, text: string) => { let newForm = {...form}; newForm[tag] = text; setForm(newForm); nestedFormCallback(ADDRESS_KEY, newForm); }; return ( Address Line 1 handleTextChange('address_line_1', text) } /> City handleTextChange('city', text)} /> State Provice handleTextChange('state_province', text) } /> Postal Code handleTextChange('postal_code', text)} /> Country Code handleTextChange('country_code', text) } /> ); };