Intro Example
在我们开始之前,这里是一个简单的 ReasonReact API 的概述。如果你发现其中一些东西(语法)你觉得不熟悉,没关系,这篇文档会涵盖所有的内容。
The component "Greeting"
/* file: Greeting.re */
[@react.component]
let make = (~name) =>
<button> {ReasonReact.string("Hello " ++ name ++ "!")} </button>;
A usage of the component
(assuming there's a div
on the page with id greeting
)
/* file: Index.re */
ReactDOMRe.renderToElementWithId(<Greeting name="John" />, "greeting");