rescript-react
rescript-react copied to clipboard
Props overwritten when they have the same prefix followed by underscores
This rescript component:
@react.component
let make = (
~foo__one,
~foo__two,
) => {
<div>
{foo__one->React.string}
{foo__two->React.string}
</div>
}
Generates this javascript function:
function Playground(Props) {
var foo__one = Props.foo;
var foo__two = Props.foo;
return React.createElement("div", undefined, foo__one, foo__two);
}
Notice that foo__one and foo__two are both assigned the value of Props.foo.
The result is that the value passed for ~foo__one get's rendered twice and ~foo_two is ignored.
It would be helpful if this at least generated a warning.
++ @rickyvetter is this for the JSX ppx?
Hmm. this is interesting. Definitely an interaction issue between the compiler mangling rules and the PPX. I think the PPX can force it to be avoided if we account for this in our naming convention and do something like this.
@mattdamon108 Is this still an issue with JSX 4?
Yes, this issue is gone with v4
function Underscore(props) {
return React.createElement("div", undefined, props.foo__one, props.foo__two);
}
@mattdamon108 Ok, then I would suggest to close this issue as fixed in v4 (unless you would like to spend time on fixing this in the v3 PPX).