Created
December 13, 2018 19:27
-
-
Save fakenickels/ae34c10d97ff25e7a98c5abd8582c14e to your computer and use it in GitHub Desktop.
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
type hoc = ReasonReact.reactClass => ReasonReact.reactClass; | |
type router; | |
module WithRouter = { | |
[@bs.module "react-router"] external withRouter : hoc = | |
"withRouter"; | |
type children = (~router: router) => ReasonReact.reactElement; | |
let component = ReasonReact.statelessComponent("WithRouter"); | |
let make' = (~router: router, children: children) => { | |
...component, | |
render: (_self) => children(~router) | |
}; | |
let jsComponent = | |
ReasonReact.wrapReasonForJs( | |
~component, | |
(props: {. "router": router, "children": children}) => | |
make'(~router=props##router, props##children) | |
); | |
let enhanced = withRouter(jsComponent); | |
let make = (children: children) => | |
ReasonReact.wrapJsForReason(~reactClass=enhanced, ~props=Js.Obj.empty(), children); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment