The Truth Table in React

true && <Component/> {/* will render the component*/}false && <Component/> {/* will hide the component*/}
true && true => true false && true => false 
data={false || []} {/* sends the empty array to Blog component */}
false || true => true
true || true => true

|| behaviour is to return the first truthy value, opposite to && which returns last truthy value

data={true || []} {/* sends posts array to Blog component*/}

--

--

--

Software developer, writing about React, Javascript & Typescript

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Brief History of CSS-in-JS: How We Got Here and Where We’re Going

7 JavaScript Libraries for Data Manipulation, Visualization, and Machine Learning.

Designing Restful APIs using an API-First Approach — Documentation

React-Router-DOM: How to Pass in Props Within a Redirect

@Order Annotation in Spring Boot

Teaching to learn: First Unique Character in a String

READ/DOWNLOAD#! Introduction to JavaScript Object

The Reverse Integer challenge.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mazen

Mazen

Software developer, writing about React, Javascript & Typescript

More from Medium

Learning reusable REACT

The useContext() hook in React

React Most Important Topic You Should Be Expert