Title: How to Optimize React Native Form Page with react-native-paper TextInput for Better Performance?

I’m developing a form page in React Native using TextInput from react-native-paper. The page is experiencing slow load times and glitches when the screen orientation changes for adujusting the width and height of the inputs. Below is a simplified version of my code:
The page takes too long to load.
There are glitches when changing the screen orientation.
How can I optimize the load time of this form page?
What are the best practices for handling screen orientation changes smoothly in React Native?
Are there specific techniques or libraries that can help improve the performance of forms with multiple TextInput components?
I’ve been exploring various optimization techniques but haven’t found a satisfactory solution yet. Any guidance or suggestions would be greatly appreciated!

import {
  Alert,
  KeyboardAvoidingView,
  LayoutAnimation,
  ScrollView,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} from 'react-native';
import React, {useMemo, useState} from 'react';
import {Checkbox, TextInput} from 'react-native-paper';
import { useOrientationChange } from 'react-native-orientation-locker';

const MemoTextInput = React.memo(TextInput);

type Form = {
  name: string;
  dob: Date | undefined;
  age: number | null;
  temporaryAddress: {
    address: string;
    city: string;
    state: string;
    country: string;
    pincode: number | null;
  };
  permanentAddress: {
    address: string;
    city: string;
    state: string;
    country: string;
    pincode: number | null;
  };
  mobile: number | null;
  education: {
    school: string;
    degree: string;
    field: string;
    startDate: Date | null;
    endDate: Date | null;
  };
};

const Forms: React.FC = () => {
  const {colors} = useTheme();
  const screenContext = useScreenContext();
  const isPortrait = screenContext.windowWidth > screenContext.windowHeight;
  
  const screenStyles = useMemo(() => {
    return styles(
      screenContext,
      screenContext[isPortrait ? 'windowWidth' : 'windowHeight'],
      screenContext[isPortrait ? 'windowHeight' : 'windowWidth'],
      colors,
    );
  }, [screenContext, isPortrait, colors]);

  const [isDate, setisDate] = useState(false);
  const [checked, setChecked] = React.useState(false);
  const currentYear = new Date().getFullYear();

  const [formData, setFormData] = useState<Form>({
    name: '',
    mobile: null,
    permanentAddress: {
      address: '',
      city: '',
      country: '',
      pincode: null,
      state: '',
    },
    temporaryAddress: {
      address: '',
      city: '',
      country: '',
      pincode: null,
      state: '',
    },
    dob: undefined,
    age: null,
    education: {
      degree: '',
      endDate: null,
      field: '',
      school: '',
      startDate: null,
    },
  });

  const handleInputChange = (
    field: keyof Form,
    value: any,
    subField?: string,
  ) => {
    setFormData(prevFormData => {
      if (
        field === 'permanentAddress' ||
        field === 'temporaryAddress' ||
        field === 'education'
      ) {
        return {
          ...prevFormData,
          [field]: {
            ...prevFormData[field],
            [subField!]: value,
          },
        };
      } else {
        return {
          ...prevFormData,
          [field]: value,
        };
      }
    });
  };

  useMemo(() => {
    if (formData.dob) {
      let userAge = currentYear - formData?.dob?.getFullYear();
      setFormData(prevFormData => ({
        ...prevFormData,
        age: userAge,
      }));
    }
  }, [formData.dob]);

  useOrientationChange(() => {
    LayoutAnimation.configureNext({
      duration: 500,
      create: {type: 'linear', property: 'scaleXY'},
      update: {type: 'spring', springDamping: 90},
      delete: {type: 'linear', property: 'opacity'},
    });
  });

  return (
    <ScrollView>
      <KeyboardAvoidingView enabled style={screenStyles.container}>
        <View id="content" style={screenStyles.contentContainer}>
          <MemoTextInput
            label="Name"
            placeholder="name"
            mode="outlined"
            value={formData.name}
            onChangeText={value => handleInputChange('name', value)}
            style={screenStyles.inputContainer}
          />
          <MemoTextInput
            label="Mobile"
            placeholder="Mobile Number"
            value={formData.mobile?.toString()}
            onChangeText={value => handleInputChange('mobile', value)}
            mode="outlined"
            style={screenStyles.inputContainer}
          />
          <View style={screenStyles.inputContainer}>
            <DatePickerComponent
              setNewDate={value => handleInputChange('dob', value)}
            />
          </View>
          {formData.age !== null && (
            <View>
              <Text style={{color: colors.text, textAlign: 'left'}}>
                {formData.age} Years
              </Text>
            </View>
          )}
          <MemoTextInput
            label="address"
            value={formData.permanentAddress.address?.toString()}
            onChangeText={value =>
              handleInputChange('permanentAddress', value, 'address')
            }
            mode="outlined"
            style={screenStyles.inputContainer}
          />
          <MemoTextInput
            label="state"
            value={formData.permanentAddress.state?.toString()}
            onChangeText={value =>
              handleInputChange('permanentAddress', value, 'state')
            }
            mode="outlined"
            style={screenStyles.inputContainer}
          />
          <MemoTextInput
            label="pincode"
            value={formData.permanentAddress.pincode?.toString()}
            onChangeText={value =>
              handleInputChange('permanentAddress', value, 'pincode')
            }
            mode="outlined"
            style={screenStyles.inputContainer}
          />
          <MemoTextInput
            label="city"
            value={
              checked
                ? formData.permanentAddress.city?.toString()
                : formData.temporaryAddress.city?.toString()
            }
            onChangeText={value =>
              handleInputChange('temporaryAddress', value, 'city')
            }
            readOnly={checked ? true : false}
            mode="outlined"
            style={screenStyles.inputContainer}
          />
          <MemoTextInput
            label="state"
            value={
              checked
                ? formData.permanentAddress.state?.toString()
                : formData.temporaryAddress.state?.toString()
            }
            onChangeText={value =>
              handleInputChange('temporaryAddress', value, 'state')
            }
            mode="outlined"
            readOnly={checked ? true : false}
            style={screenStyles.inputContainer}
          />
        </View>
      </KeyboardAvoidingView>
    </ScrollView>
  );
};

export default React.memo(Forms);

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật