February 2019
Beginner to intermediate
180 pages
4h 4m
English
Let's add a few props to our <App /> component:
let make = (~greeting, ~name, _children) => { ...component, render: _self => <div> {ReasonReact.string(greeting ++ " " ++ name)} </div>,};
After compiling, we get a compiler error, because in Index.re we aren't providing the required greeting and name props:
We've found a bug for you! 1 │ ReactDOMRe.renderToElementWithId(<App />, "root"); This call is missing arguments of type:(~greeting: string),(~name: string)
greeting and name are labelled arguments of the make function, meaning that they can be provided in any order. To convert an argument to a labelled argument, prefix it with a tilde (~). Reason also supports optional arguments as well as arguments with defaults. Let's give greeting ...
Read now
Unlock full access