Hello, I would like to requets a feature that has to do with the way the HTML part of the JSX is written.
Today, to pass a prop that has the same name as the variable that carries the information, here is the behavior:
<Forum subjects={subjects} />
I (but not solely I, I'm sure) would love to be able to write this:
<Forum subjects />
I know that HTML allows this for booleans, but as JSX is neither HTML nor JS, I'm sure we can work something out to allow this for objects, the same way it's done in ES6:
console.log({ nameOfTheVariable })
for instance.
JSX also treats attributes with no value as booleans like:
<Forum subjects />
Is the same as:
<Forum subjects={true} />
Maybe surrounding the attribute name with braces would be a good way to differentiate the behaviour and allow what you are asking for to work without conflicts:
<Forum {subjects} />
To be a syntatic sugar for:
<Forum subjects={subjects} />
Definitely, that'd be great !
JSX isn't part of React itself and is used by other libraries as well. There is an official specification and repo for JSX. I recommend you refer to those resources, as there is already an open issue for this. Thanks!
Most helpful comment
JSX also treats attributes with no value as booleans like:
Is the same as:
Maybe surrounding the attribute name with braces would be a good way to differentiate the behaviour and allow what you are asking for to work without conflicts:
To be a syntatic sugar for: