DEV Community

Discussion on: Hooked with React - Creating book details page using react router, Part 4

Collapse
 
syed456 profile image
syed

hi Paramanantham,
thanks for your 4 parts tutorials.
Whats the difference between below 2 ways of rendering? I feel second option is more appropriate as its not going to load Loader component at all, if Loader = false. Or I miss something? please explain

  <Loader searchTerm={searchTerm} loading={loading} />

AND
Loader &&

Thanks
syed

Collapse
 
learnwithparam profile image
Paramanantham Harrison

Yes, second option is conditional loading. If the condition is false, then it won’t load the component

Collapse
 
syed456 profile image
syed

which way is more appropriate over other one is my confusion. I saw both the cases many places. It look conditional rendering is better for me, if I'm not wrong, since if condition is false, then no need for React to load Loader component , by this way we are optimizing the memory or whatever.