How do I get data from function before building UI

Hey guys, so I have a function that sorts and fetches data from Firestore, but I cant get the function to run before the page/component is constructed?

Here is the function I need to run before the component

setupPageData();

const Tab1: React.FC = () => {
  return (
    <IonPage>
      <IonHeader>
        <IonToolbar>
          <IonTitle>Lockdown Status</IonTitle>
        </IonToolbar>

You need to familiarize yourself with React Lifecycle methods.

I agree it is important to understand React Lifecycle methods, I strongly recommend that you look at the ionic documentation that is specific to Ionic - React Lifecycle - Ionic Documentation (ionicframework.com)

I did spend the last few days going through some React and Ionic courses and it has really helped me understand what I need to do a lot