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

114
Views
component is getting loaded for fraction of second in React

I have one query call which returns me the data and also I am using await as well.

const {data, isLoading }  =  useQuery('getData', queryFunc);

here ,

I am trying to use it here

 <div>
    { data?.addition?.isEnabled && <Notification> }
    </div>

Here, for fraction of second the Notification component is getting rendered., and after 1-2 second once response comes then the component is rendered.

Is there any specific reason for this? also How do I fix this ?

I fixed this like  { data && data?.addition?.isEnabled && <Notification> }

can any one help me with this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In React undefined and false values are not rendered. Since the data you're getting is from an async function the notifications component will be rendered briefly until initialized and then removed. You can maybe use a useCallback hook to fix this behavior but without seeing more of the code I'm not sure on what to do. Usage of useCallback is like so:

const foo = useCallback(() => { //you can pass parameters here when calling like this foo(arg1,arg2)
   //do something expensive in resources...
   //this will re-render when done.
   return bar;
 },[//dependencies go here]);
 //use with useEffect hook if you want this to render on load like so:
 useEffect(() => {
    foo();
 },[foo]);
about 4 years ago · Juan Pablo Isaza 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!