Permalink
Browse files

examples/reason-react-app: handle error pages

  • Loading branch information...
MoOx committed Feb 26, 2018
1 parent 7efdffa commit b0f585622dd6eec1d553d6545cd2ee0716d504f5
@@ -1,10 +1,11 @@
import * as React from "react";
import { Router, Route, browserHistory } from "react-router";
import { createApp, renderApp } from "@phenomic/preset-react-app/lib/client";
import { createContainer } from "@phenomic/preset-react-app/lib/es6_global/src/phenomicPresetReactApp.js";
import { createContainer } from "@phenomic/preset-react-app/lib/es6/src/phenomicPresetReactApp.js";
import * as Home from "./lib/es6_global/src/components/Home";
import * as Post from "./lib/es6_global/src/components/Post";
import * as Home from "./lib/es6/src/components/Home";
import * as Post from "./lib/es6/src/components/Post";
import ErrorPage from "./lib/es6/src/components/ErrorPage";
const routes = () => (
<Router history={browserHistory}>
@@ -20,6 +21,8 @@ const routes = () => (
path="blog/*"
component={createContainer(Post.jsComponent, Post.queries)}
/>
<Route path="*" component={ErrorPage} />
<Route path="404.html" component={ErrorPage} />
</Router>
);
@@ -0,0 +1,21 @@
open Helpers;
let component = ReasonReact.statelessComponent("Post");
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>
};
let default =
ReasonReact.wrapReasonForJs(~component, jsProps =>
make(~message=?Js.Nullable.to_opt(jsProps##message), [||])
);
@@ -10,7 +10,7 @@ let make = (~post) => {
switch (post: Types.postNode) {
| Inactive
| Loading => "Loading ..." |> text
| Errored => "An error occured" |> text
| Errored => <ErrorPage />
| Idle(post) =>
<div>
<Head> <title> (post##title |> text) </title> </Head>

0 comments on commit b0f5856

Please sign in to comment.