react-bits
react-bits copied to clipboard
Another Approach for conditional Rendering
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