Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
How to check if items are loaded?

I have three different item types: courses, packages and programs. I can either filter by All, or by the three Types mentioned before. How can I check the case in which ALL items are loaded, not just these three individually? I want to show a loading spinner in case the items are not loaded. Here's what I have so far:

 const [isLoading,   setIsLoading]   = React.useState<boolean>(false);

 React.useEffect(() => {
    setCourses([]);
    setPrograms([]);
    setPackages([]);

    if([DataType.Course, "all"].includes(contentType))
      Course.get(undefined, useCatalog, parent).then(async (c: Course[]) => {
        setCourses(c || []);
        setIsLoading(false)
      })
    if([DataType.Program, "all"].includes(contentType) && (!parent || parent.data_type === DataType.Package))
      Program.get(undefined, useCatalog, parent).then((p: Program[]) => {
        setPrograms(p ||[]),
        setIsLoading(false)
    });
    if([DataType.Package, "all"].includes(contentType) && !parent)
      Package.get(undefined, useCatalog).then((p: Package[]) => {
        setPackages(p || []),
        setIsLoading(false)
      });
  }, [contentType, useCatalog, parent]);
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

consider use 3 different isLoading state? e.g. isLoadingCourses, isLoadingPrograms, isLoadingPackages then do something like

if (!isLoadingCourses || !isLoadingPrograms || !isLoadingPackages) return <Spinner/>

or you can check directly the items like

if (!courses || !programs || !packages) return <Spinner/>
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!