Unnecessary braces when autocompleting JSX props
Example:
type myVariant = AAAAA | BBBBB
module MyComponent = {
@react.component
let make = (~x: myVariant) => (x :> string)->React.string
}
<MyComponent x=
Autcomplete correctly suggests AAAAA and BBBBB. When I select AAAAA, I get
<MyComponent x={AAAAA}
The braces are unnecessary here, so I usually remove them again manually to get
<MyComponent x=AAAAA
I actually prefer having curly braces, mostly because of how it is in React JS.
Yeah this is actually intentional, and it's to be uniform (can always have braces, can not always not have braces). Plus, make it easier to change the expression. If you add a pipe to AAAAA in the example above you'll need to wrap with braces anyway or you get a somewhat non obvious syntax error.
In my perception, this just adds visual noise.
But if we want to standardize on having the braces because that's how it is in React JS, then maybe
<MyComponent x=AAAAA
actually should be reformatted to
<MyComponent x={AAAAA}
?
In my perception, this just adds visual noise.
But if we want to standardize on having the braces because that's how it is in React JS, then maybe
<MyComponent x=AAAAA actually should be reformatted to
<MyComponent x={AAAAA} ?
I can add this to the formatter to always add braces if we decided that we should do it this way.
I prefer not to have curly braces if I don't need them, and JS React also has something similar with strings compared to template literals.
<Foo name="Joe" />
<Bar name={`${firstname} ${lastname}`} />
To me this seems like a precedent that in React curly braces are only used when required, and if in ReScript there are more cases where we can omit them, we should.
I agree that curly braces shouldn't be added if they are not necessary (but the formater should keep them if you prefer to write them)
Ok, there seems to be some consensus that we should not add braces for every prop.
But then I would appreciate it if editor completion did not add it automatically in unnecessary cases either.
I do understand this argument though
Yeah this is actually intentional, and it's to be uniform (can always have braces, can not always not have braces). Plus, make it easier to change the expression. If you add a pipe to AAAAA in the example above you'll need to wrap with braces anyway or you get a somewhat non obvious syntax error.