-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Hi @ryyppy,
Rescript beginner here, I'm digging around nextjs with rescript.
I've seen in all your pages that you can't re-export directly the default, because of fast refresh and the name $$default of the components.
However, if we use the @react.component decorator, the name will not be only default but MyModule$default which totaly satitisfy FastRefresh:
module Label = {
@react.component
let make = (~title: string) => {
<div className="myLabel"> {React.string(title ++ "foo")} </div>
}
}
@react.component
let default = () => {
<div>
<Label title="Getting Started" />
{React.string("foo")}
</div>
}⇣⇣⇣
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as React from "react";
function MyTest$Label(Props) {
var title = Props.title;
return React.createElement("div", {
className: "myLabel"
}, title + "foo");
}
var Label = {
make: MyTest$Label
};
function MyTest$default(Props) {
return React.createElement("div", undefined, React.createElement(MyTest$Label, {
title: "Getting Started"
}), "foo");
}
var $$default = MyTest$default;
export {
Label ,
$$default ,
$$default as default,
}
/* react Not a pure module */My next page is here only:
export { default } from 'modules/MyTest.bs.js'So why not use the decorator on the default component?
Thanks.
Mathieu.
Metadata
Metadata
Assignees
Labels
No labels