react-bits icon indicating copy to clipboard operation
react-bits copied to clipboard

Another Approach for conditional Rendering

Open aniketsingh98571 opened this issue 6 months ago • 0 comments

We can make use of switch statements if the conditions are too complex and long, Example:-

let componentToRender=null;
const admin=true
switch(admin){
   case true:
       componentToRender=<Admin/>
       break;
   case false:
       componentToRender=<User/>
}

return (
  {componentToRender}
)

File - https://github.com/vasanthk/react-bits/blob/master/patterns/1.conditionals-in-jsx.md

aniketsingh98571 avatar Aug 16 '24 15:08 aniketsingh98571