reactjs – React js state management if-else condition

There is no difference, in either case the same jsx – ComponentA will render.

The reasoning:

a) isTrue is a truthy value in either case

// It is an empty object - more specifically

// let us see this below

const isTrue = {}

isTrue ? true : false // will result true

b) The logical && expression, isTrue && Component A, will evaluate true and return the right-side value which is the component Component A.

c) !isTrue && Component A, will evaluate to a false value, which React will ignore from rendering.

d) Fragment tag <>> does not have any trace in the resultant HTML

Read more here: Source link