PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, April 15, 2022

[FIXED] what is difference Three-way operator( ~ ? a: b). and Alternative operator. in my code

 April 15, 2022     iframe, javascript, loader, operator-keyword, reactjs     No comments   

Issue

<>
   {isLoading || <Loader />}
   <iframe
     ref={iframeRef}
     title="title"
     src={src}
     onLoad={onIframeLoad}
   />
</>

I wrote the code like this at first. this code is in react and with
const [isLoading, setIsLoading] = useState(true) and In the onIframeLoad func With other works, i doing setIsLoading(false)

so i think loader component i cant see but i can see iframe with loader ???

so i changed the code {isLoading || } => {isLoading ? : ''} then it work well

but i dont understand what is difference code meaning


Solution

<Loader /> component will be visible when isLoading is false in your code.

{isLoading || <Loader />} should be {isLoading && <Loader />}.

<>
   {isLoading && <Loader />}
   <iframe
     ref={iframeRef}
     title="title"
     src={src}
     onLoad={onIframeLoad}
   />
</>


Answered By - zmag
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing