-
-
Save thangngoc89/9b8776cdc4e3ad1b72dc5dc5d3a28658 to your computer and use it in GitHub Desktop.
Async import pattern
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
| PageModule.fetchModule("./MyComponent") | |
| |> Js.Promise.then_(m => send(SetRootElement(m()))); |
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
| let component = ReasonReact.statelessComponent("MyComponent"); | |
| let make = (_) => { | |
| ...component, | |
| render: (_) => <div /> | |
| }; | |
| let make = () => make([||]); |
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
| include PageModule.M; |
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
| module type M = { | |
| let make: unit => ReasonReact.reactElement; | |
| }; | |
| type m = Js.t({ . make: unit => ReasonReact.reactElement }); | |
| [@bs.val] external fetchModule: string => Js.Promise.t(m) = "import"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment