Engineering note · React Js

Conditional Rendering with Short Circuit

By Published Updated

React Js

if you don’t need the else block while rendering components in React Js, you can do like this

CODE SAMPLE Code snippet
{isLoggedIn && <AdminPanel />}

This snippet conditionally renders the AdminPanel component. The && operator is used here as a shorthand for if statements.

If isLoggedIn is true, AdminPanel will be displayed; if false, nothing will be rendered.

More engineering notes

Destructuring Props in Functional Components

When you pass any props to any componenet, as in this example passing name and age as props to Profi...

Using useMemo for Caching and Optimizing Performance

~~`useMemo`~~ is a React Hook that helps optimize performance by memoizing (caching) the result of a...