Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

[Feature] Update ReasonReact JSX to version 3 #1279

Merged
merged 15 commits into from
May 28, 2019
12 changes: 3 additions & 9 deletions examples/reason-react-app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ import ErrorPage from "./lib/es6/src/components/ErrorPage.bs.js";

const routes = () => (
<Router history={browserHistory}>
<Route
path="/"
component={withPhenomicApi(Home.jsComponent, Home.queries)}
/>
<Route path="/" component={withPhenomicApi(Home.make, Home.queries)} />
<Route
path="/after/:after"
component={withPhenomicApi(Home.jsComponent, Home.queries)}
/>
<Route
path="blog/*"
component={withPhenomicApi(Post.jsComponent, Post.queries)}
component={withPhenomicApi(Home.make, Home.queries)}
/>
<Route path="blog/*" component={withPhenomicApi(Post.make, Post.queries)} />
<Route path="*" component={ErrorPage} />
<Route path="404.html" component={ErrorPage} />
</Router>
Expand Down
2 changes: 1 addition & 1 deletion examples/reason-react-app/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/example-reason-react-app",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"suffix": ".bs.js",
"package-specs": {
Expand Down
6 changes: 3 additions & 3 deletions examples/reason-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"private": true,
"name": "@phenomic/example-reason-react-app",
"devDependencies": {
"@moox/bs-react-helmet": "^1.0.0",
"@moox/bs-react-helmet": "^2.0.0",
"@phenomic/cli": "^1.0.0-beta.11",
"@phenomic/core": "^1.0.0-beta.11",
"@phenomic/preset-react-app": "^1.0.0-beta.11",
"bs-platform": "^5.0.0",
"bs-platform": "^5.0.4",
"npm-run-all": "^4.0.2",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"react-helmet": "^5.2.0",
"react-router": "^3.2.0",
"reason-react": "^0.6.0"
"reason-react": "^0.7.0"
},
"scripts": {
"reason:cleanup": "bsb -clean-world",
Expand Down
6 changes: 3 additions & 3 deletions examples/reason-react-app/src/Helpers.re
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let nothing = ReasonReact.null;
let nothing = React.null;

let text = ReasonReact.string;
let text = React.string;

let list = list => list |> Array.of_list |> ReasonReact.array;
let list = list => list |> Array.of_list |> React.array;

let nodeList = node => node##list |> Array.to_list;
22 changes: 8 additions & 14 deletions examples/reason-react-app/src/components/ErrorPage.re
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
open Helpers;

let component = ReasonReact.statelessComponent("Post");

[@react.component]
let make = (~message: option(string)=?, _) => {
...component,
render: _self =>
<div style={ReactDOMRe.Style.make(~fontSize="80px", ())}>
{switch (message) {
| None => "An error occured" |> text
| Some(msg) => msg |> text
}}
</div>,
<div style={ReactDOMRe.Style.make(~fontSize="80px", ())}>
{switch (message) {
| None => "An error occured" |> text
| Some(msg) => msg |> text
}}
</div>;
};

let default =
ReasonReact.wrapReasonForJs(~component, jsProps =>
make(~message=?Js.Nullable.toOption(jsProps##message), [||])
);
let default = make;
107 changes: 50 additions & 57 deletions examples/reason-react-app/src/components/Home.re
Original file line number Diff line number Diff line change
@@ -1,66 +1,59 @@
open Helpers;

let component = ReasonReact.statelessComponent("Home");

[@react.component]
let make = (~posts) => {
...component,
render: _self =>
<div>
<BsReactHelmet>
<title> {"Hello world" |> text} </title>
<meta name="description" content="Everything is awesome!" />
</BsReactHelmet>
<h1> {"Home" |> text} </h1>
{switch ((posts: Types.posts)) {
| Inactive
| Loading => "Loading ..." |> text
| Errored => "An error occured" |> text
| Idle(posts) =>
let postsList = posts##list |> Array.to_list;
let posts' = PhenomicPresetReactApp.jsEdge(posts);
<div>
<BsReactHelmet>
<title> {"Hello world" |> text} </title>
<meta name="description" content="Everything is awesome!" />
</BsReactHelmet>
<h1> {"Home" |> text} </h1>
{switch ((posts': Types.posts)) {
| Inactive
| Loading => "Loading ..." |> text
| Errored => "An error occured" |> text
| Idle(posts) =>
let postsList = posts##list |> Array.to_list;
<div>
<ul>
{postsList
|> List.map(item =>
<li key=item##id>
<PhenomicPresetReactApp.Link
href={"/blog/" ++ item##id ++ "/"}>
{item##title |> text}
</PhenomicPresetReactApp.Link>
</li>
)
|> list}
</ul>
<div>
<ul>
{postsList
|> List.map(item =>
<li key=item##id>
<PhenomicPresetReactApp.Link
href={"/blog/" ++ item##id ++ "/"}>
{item##title |> text}
</PhenomicPresetReactApp.Link>
</li>
)
|> list}
</ul>
<div>
{switch (posts##previous |> Js.toOption) {
| Some(previous) =>
<PhenomicPresetReactApp.Link
href={
posts##previousPageIsFirst
? "/" : "/after/" ++ previous ++ "/"
}>
{"Newer posts" |> text}
</PhenomicPresetReactApp.Link>
| None => nothing
}}
{" " |> text}
{switch (posts##next |> Js.toOption) {
| Some(next) =>
<PhenomicPresetReactApp.Link href={"/after/" ++ next ++ "/"}>
{"Older posts" |> text}
</PhenomicPresetReactApp.Link>
| None => nothing
}}
</div>
</div>;
}}
</div>,
{switch (posts##previous |> Js.toOption) {
| Some(previous) =>
<PhenomicPresetReactApp.Link
href={
posts##previousPageIsFirst
? "/" : "/after/" ++ previous ++ "/"
}>
{"Newer posts" |> text}
</PhenomicPresetReactApp.Link>
| None => nothing
}}
{" " |> text}
{switch (posts##next |> Js.toOption) {
| Some(next) =>
<PhenomicPresetReactApp.Link href={"/after/" ++ next ++ "/"}>
{"Older posts" |> text}
</PhenomicPresetReactApp.Link>
| None => nothing
}}
</div>
</div>;
}}
</div>;
};

let jsComponent =
ReasonReact.wrapReasonForJs(~component, jsProps =>
make(~posts=PhenomicPresetReactApp.jsEdge(jsProps##posts))
);

let queries = props => {
let posts =
PhenomicPresetReactApp.query(
Expand Down
41 changes: 17 additions & 24 deletions examples/reason-react-app/src/components/Post.re
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
open Helpers;

let component = ReasonReact.statelessComponent("Post");

[@react.component]
let make = (~post) => {
...component,
render: _self =>
<div>
{switch ((post: Types.postNode)) {
| Inactive
| Loading => "Loading ..." |> text
| Errored => <ErrorPage />
| Idle(post) =>
<div>
<BsReactHelmet>
<title> {post##title |> text} </title>
</BsReactHelmet>
<h1> {post##title |> text} </h1>
<PhenomicPresetReactApp.BodyRenderer body=post##body />
</div>
}}
</div>,
let post' = PhenomicPresetReactApp.jsEdge(post);
<div>
{switch ((post': Types.postNode)) {
| Inactive
| Loading => "Loading ..." |> text
| Errored => <ErrorPage />
| Idle(post) =>
<div>
<BsReactHelmet>
<title> {post##title |> text} </title>
</BsReactHelmet>
<h1> {post##title |> text} </h1>
<PhenomicPresetReactApp.BodyRenderer body=post##body />
</div>
}}
</div>;
};

let jsComponent =
ReasonReact.wrapReasonForJs(~component, jsProps =>
make(~post=PhenomicPresetReactApp.jsEdge(jsProps##post))
);

let queries = props => {
let post =
PhenomicPresetReactApp.query(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.0",
"babel-jest": "^23.6.0",
"bs-platform": "^5.0.0",
"bs-platform": "^5.0.4",
"chalk": "^1.1.3",
"cross-env": "^2.0.0",
"cross-spawn": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/api-client",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/babel-preset",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/bs-platform/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/bs-platform",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [],
"suffix": ".bs.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/bs-platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lib/**/*.js"
],
"devDependencies": {
"bs-platform": "^5.0.0",
"bs-platform": "^5.0.4",
"cpy-cli": "^2.0.0",
"replace": "^1.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/cli",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/core",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/helpers-transform/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/helpers-transform",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-api-related-content/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/plugin-api-related-content",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-bundler-webpack/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/plugin-bundler-webpack",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-collector-files/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/plugin-collector-files",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-public-assets/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/plugin-public-assets",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-renderer-react/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@phenomic/plugin-renderer-react",
"refmt": 3,
"reason": {
"react-jsx": 2
"react-jsx": 3
},
"sources": [
{
Expand Down
Loading