Conditions in React with JSX

JSX is a statically-typed, object-oriented programming language designed to run on modern web browsers. It is an XML-like syntax extension. It allows us to create and write HTML elements in javascript and place them in DOM without any javascript function like createElement() or appendChild(), etc.

So, JSX syntax is a really cool and the best feature of React. You can use this trick in the components of React to improve your capabilities. You can make shorter conditions with JSX instead of using normal conditions in React components.

See the following example of JSX syntax in React.

Instead of using

you can use the following shorter condition.

Also Read: How to inline style in ReactJS?

Being Tricky 😉

Leave a Reply

Your email address will not be published.