Created
December 1, 2018 03:45
-
-
Save dangdennis/b12619bd9fc4f6f3dd71bf4554284d8c to your computer and use it in GitHub Desktop.
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
module ChildComponent = { | |
let component = ReasonReact.statelessComponent("ChildComponent"); | |
/* You must declare your props as labeled arguments with the ~ symbol */ | |
/* If I don't, compile error: It only accepts 1 argument; here, it's called with more. */ | |
let make = (~randomTextProp, _children) => { | |
...component, | |
render: _self => <p> {ReasonReact.string(randomTextProp)} </p>, | |
}; | |
}; | |
module ParentComponent = { | |
let component = ReasonReact.statelessComponent("ParentComponent"); | |
/* Compiler throws warnings if variables are unused */ | |
/* Ignore variables with _ */ | |
let make = _children => { | |
...component, | |
render: _self => | |
/* Passing down some text as prop */ | |
<ChildComponent randomTextProp="Hey I'm a prop" />, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment