You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to current syntax, a JSX attribute without an initializer is set to boolean true.
However, there is no such shortcut equivalent for initializing an attribute for false so in this case the full form must be used explicitly.
My proposal is to allow an ! prefix before the attribute name as shortcut for false.
For example,
<MyComp visible/> is equivalent today to <MyComp visible={true} />
<MyComp !visible /> will become equivalent to <MyComp visible={false} />
This is quite a common case that is needed for JSX attributes whose default value is defined as true. It helps reduce unnecessary clutter and simplify JSX expressions.
This syntax extension is backward compatible with current grammar and can be added without impact on any existing JSX codebase.
The text was updated successfully, but these errors were encountered:
According to current syntax, a JSX attribute without an initializer is set to boolean
true
.However, there is no such shortcut equivalent for initializing an attribute for
false
so in this case the full form must be used explicitly.My proposal is to allow an
!
prefix before the attribute name as shortcut forfalse
.For example,
<MyComp visible/>
is equivalent today to<MyComp visible={true} />
<MyComp !visible />
will become equivalent to<MyComp visible={false} />
This is quite a common case that is needed for JSX attributes whose default value is defined as
true
. It helps reduce unnecessary clutter and simplify JSX expressions.This syntax extension is backward compatible with current grammar and can be added without impact on any existing JSX codebase.
The text was updated successfully, but these errors were encountered: