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

77
Views
Can we pass errors as props from catch block in reactJS and show them in new reusable component where props will resemble different errors

Below method isn't working. I also tried using useHistory but how to pass props using useHistory , Redirect method also not working

For example

Inside Functional Component{



 instance.get(url).catch((error)=>{

 
        if(error.response){

          if(error.response.status===404){
                  
                   <ErrorComponent err={error.response.status}/>
                   console.log("Page Not Found");
               }
          if(error.response.status===400){
                
               <ErrorComponent err={error.response.status}/>
               console.log("Bad Request")
           }
      }
  }
}
about 4 years ago · Juan Pablo Isaza
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!