Created
May 4, 2019 02:17
-
-
Save sync/de41f65adea48ca764c275004b32fced to your computer and use it in GitHub Desktop.
Next.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type css = {. "about": string}; | |
[@bs.module] external css: css = "./about.css"; | |
[@react.component] | |
let make = (~onServer) => { | |
<div | |
className={ | |
css##about; | |
}> | |
<p> {React.string("This is the about page.")} </p> | |
<p> {React.string("onServer: " ++ string_of_bool(onServer))} </p> | |
<Counter /> | |
</div>; | |
}; | |
let getInitialProps = context => { | |
let onServer = | |
switch (Js.Nullable.toOption(context##req)) { | |
| None => false | |
| Some(_) => true | |
}; | |
{"onServer": onServer}; | |
}; | |
let default = make; | |
let inject: | |
( | |
Js.t('a) => React.element, | |
{. "req": Js.Nullable.t(Js.t('a))} => Js.t('a) | |
) => | |
unit = [%bs.raw | |
{| (cls, fn) => cls.getInitialProps = fn |} | |
]; | |
inject(default, getInitialProps); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment