Open Lordfirespeed opened 5 days ago
Ran into the same issue. In an expression you can use \u00a0
.
Is there a reason why you use that instead of <>{" "}</>
?
Is there a reason why you use that instead of
<>{" "}</>
?
My phone has actually perfectly demoed why:
Regular space can cause unwanted line-breaks.
But do you have a demo in a react JSX project that causes that?
I don't see why the playground link supplied with the issue is insufficient
I don't see why the playground link supplied with the issue is insufficient
Two reasons:
I want to understand the use case
Here's one:
import * as React from "react"
const myStrings = [ "foo", "bar", undefined, "baz" ] as const
export default function TestPage() {
return <div>
{myStrings.map((value, index) =>
<div>
{value ?? <> </>}
</div>
)}
</div>
}
The blank line is desired. With " "
, the space is perceived by the HTML parser as structurally insignificant whitespace, so its enclosing <div />
is considered empty and does not render at all.
I hope you understand this is just one example, and
can be used to ensure a (blank) line-height is rendered in myriad scenarios.
I don't understand how GitHub rendering some markdown is related to JSX
That was something of a jest on my part, so I'm sorry it confused you.
You intended to convey <>{" "}</>
but the content appeared to me as <>{"
"}</>
, which illustrates why the use of
can be necessary - I found that ironic.
i'll work on this.
Environment information
Rule name
lint/complexity/noUselessFragments
Playground link
Link
Expected result
Fragments containing HTML escapes (e.g.
) inside expression escapes{ ... }
should not be considered useless.Code of Conduct