Created
April 5, 2017 22:47
-
-
Save quicksnap/d31d06d5a83bb046653db2af572897e8 to your computer and use it in GitHub Desktop.
Crappy React-router v4 bindings
This file contains hidden or 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
external router : ReactRe.reactClass = "BrowserRouter" [@@bs.module "react-router-dom"]; | |
external link : ReactRe.reactClass = "Link" [@@bs.module "react-router-dom"]; | |
external route : ReactRe.reactClass = "Route" [@@bs.module "react-router-dom"]; | |
module Router = { | |
let createElement children::(children: list ReactRe.reactElement) => | |
ReactRe.wrapPropsShamelessly router {"children": Array.of_list children} ::children; | |
}; | |
module Link = { | |
let createElement | |
className::(className: option string)=? | |
children::(children: list ReactRe.reactElement) | |
linkTo::(linkTo: string) => | |
ReactRe.wrapPropsShamelessly | |
link | |
{ | |
"to": linkTo, | |
"children": Array.of_list children, | |
"className": Js_null_undefined.from_opt className | |
} | |
::children; | |
}; | |
module Route = { | |
let createElement | |
path::(path: string) | |
exact::(exact: bool)=false | |
component::(component: option ReactRe.reactClass)=? => | |
ReactRe.wrapPropsShamelessly | |
route | |
{ | |
"path": path, | |
"exact": Js.Boolean.to_js_boolean exact, | |
"component": Js.Null_undefined.from_opt component | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment