unicorn-utterances
unicorn-utterances copied to clipboard
[Website Bug]: Typo in website
Description
https://github.com/unicorn-utterances/unicorn-utterances/blob/main/content/crutchcorn/collections/framework-field-guide-fundamentals/posts/ffg-fundamentals-dynamic-html/index.md#react-1
I think there is an error with the conditional examples which are using OR statement instead of AND
Minimal Reproduction
We're using React's {}
JavaScript binding to add an AND
statement. This works by using Boolean logic of "short-circuiting". This means that if we have:
const val = true || {}; //=> const val = true && {};
val
will be set to {}
, while if we have:
const val = false || {}; //=> const val = false && {};
val
will be set to false
.
React then uses this return value to render the value when the condition inside the curly braces is not undefined
or null
.
This means that these examples will render their contained values:
<div>{0}</div>
<div>{"Hello"}</div>
<div>{true || <Comp/>}</div> //=> <div>{true && <Comp/>}</div>
<div>{true}</div>
// Renders as
<div>0</div>
<div>Hello</div>
<div><Comp/></div>
<div>true</div>
Exception or Error
No response