1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

example with-reasonml dependency updates (#5048)

The original example fails to compile on my windows machine but updating bs-platform fixes that.
Depending on bs-next causes example to fail (package compiled with old incompatible version of bs-platform) so I have included it in a bindings directory where it can serve as an example of reason bindings.
Sources have been migrated to the latest reason-react.
This commit is contained in:
Adam Lane 2018-09-02 16:38:54 -07:00 committed by Tim Neutkens
parent 6c1389b69e
commit 3d9564215c
7 changed files with 52 additions and 16 deletions

View file

@ -0,0 +1,37 @@
module Link = {
[@bs.module "next/link"] external link: ReasonReact.reactClass = "default";
let make =
(
~href=?,
~_as=?,
~prefetch: option(bool)=?,
~replace: option(bool)=?,
~shallow: option(bool)=?,
~passHref: option(bool)=?,
children,
) =>
ReasonReact.wrapJsForReason(
~reactClass=link,
~props=
Js.Undefined.{
"href": fromOption(href),
"as": fromOption(_as),
"prefetch": fromOption(prefetch),
"replace": fromOption(replace),
"shallow": fromOption(shallow),
"passHref": fromOption(passHref),
},
children,
);
};
module Head = {
[@bs.module "next/head"] external head: ReasonReact.reactClass = "default";
let make = children => ReasonReact.wrapJsForReason(~reactClass=head, ~props=Js.Obj.empty(), children);
};
module Error = {
[@bs.module "next/error"] external error: ReasonReact.reactClass = "default";
let make = (~statusCode: int, children) =>
ReasonReact.wrapJsForReason(~reactClass=error, ~props={"statusCode": statusCode}, children);
};

View file

@ -1,7 +1,7 @@
{ {
"name": "with-reasonml", "name": "with-reasonml",
"sources": ["components", "pages"], "sources": ["components", "pages", "bindings"],
"bs-dependencies": ["reason-react", "bs-next"], "bs-dependencies": ["reason-react"],
"reason": { "react-jsx": 2 }, "reason": { "react-jsx": 2 },
"package-specs": { "package-specs": {
"module": "commonjs", "module": "commonjs",

View file

@ -13,9 +13,9 @@ let make = (_children) => {
render: (self) => { render: (self) => {
let countMsg = "Count: " ++ string_of_int(self.state); let countMsg = "Count: " ++ string_of_int(self.state);
<div> <div>
<p> (ReasonReact.stringToElement(countMsg)) </p> <p> (ReasonReact.string(countMsg)) </p>
<button onClick=(self.reduce((_event) => Add))> <button onClick=(_event => self.send(Add))>
(ReasonReact.stringToElement("Add")) (ReasonReact.string("Add"))
</button> </button>
</div> </div>
} }

View file

@ -7,10 +7,10 @@ let make = (_children) => {
render: (_self) => render: (_self) =>
<div> <div>
<Next.Link href="/"> <Next.Link href="/">
<a style=styles> (ReasonReact.stringToElement("Home")) </a> <a style=styles> (ReasonReact.string("Home")) </a>
</Next.Link> </Next.Link>
<Next.Link href="/about"> <Next.Link href="/about">
<a style=styles> (ReasonReact.stringToElement("About")) </a> <a style=styles> (ReasonReact.string("About")) </a>
</Next.Link> </Next.Link>
</div> </div>
}; };

View file

@ -8,15 +8,14 @@
}, },
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"babel-plugin-bucklescript": "^0.2.4", "babel-plugin-bucklescript": "^0.4.0",
"next": "latest", "next": "latest",
"react": "^16.1.1", "react": "^16.4.2",
"react-dom": "^16.1.1", "react-dom": "^16.4.2",
"reason-react": "^0.3.0", "reason-react": "^0.5.3"
"bs-next": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"bs-platform": "^2.1.0", "bs-platform": "^4.0.5",
"concurrently": "^3.5.1", "concurrently": "^3.5.1",
"webpack": "^3.8.1" "webpack": "^3.8.1"
} }

View file

@ -5,7 +5,7 @@ let make = (_children) => {
render: (_self) => render: (_self) =>
<div> <div>
<Header /> <Header />
<p> (ReasonReact.stringToElement("This is the about page.")) </p> <p> (ReasonReact.string("This is the about page.")) </p>
<Counter /> <Counter />
</div> </div>
}; };

View file

@ -5,7 +5,7 @@ let make = (_children) => {
render: (_self) => render: (_self) =>
<div> <div>
<Header /> <Header />
<p> (ReasonReact.stringToElement("HOME PAGE is here!")) </p> <p> (ReasonReact.string("HOME PAGE is here!")) </p>
<Counter /> <Counter />
</div> </div>
}; };