Engineering note · React Js
Conditional Rendering with Short Circuit
By Farah Jokhio Published Updated
if you don’t need the else block while rendering components in React Js, you can do like this
{isLoggedIn && <AdminPanel />}
This snippet conditionally renders the AdminPanel component. The operator is used here as a shorthand for if statements. &&
If is true, isLoggedIn will be displayed; if false, nothing will be rendered.AdminPanel
More engineering notes
Optimizing Performance with React.memo
Wrap components in React.memo to avoid unnecessary re-renders.
Labels: Names used to label loops and control flow
Labels in Node.js (and JavaScript) are used to name a statement, typically for controlling the flow...