While in the process of writing a recursive react component, I found out that a superfluous rec
leads to a strange JS translation.
Here is a MWE:
With the following rescript code,
module A = {
@react.component
let rec a = () => React.null
}
the translated JS code leads to an infinite loop:
function a(props) {
while(true) {
continue ;
};
}
var A = {
a: a
};
Removing the rec
leads to the proper
function CommentRow$A$a(props) {
return null;
}
var A = {
a: CommentRow$A$a
};
Shouldn’t (although redundant) rec
result in the same translation?
I don’t think this happens in plain functions.
Is this a bug, or is this behavior documented somewhere?
I’m using JSX 4 with rescript 10.1.0.