我正在尝试定义一个ProductRowand ProductCategoryRowfrom Thinking in React。
productRow.re
let component = ReasonReact.statelessComponent("ProductRow");
let make = (~name, ~price, _children) => {
...component,
render: (_self) => {
<tr>
<td>{ReasonReact.stringToElement(name)}</td>
<td>{ReasonReact.stringToElement(price)}</td>
</tr>
}
};
productCategoryRow.re
let component = ReasonReact.statelessComponent("ProductCategoryRow");
let make = (~title: string, ~productRows, _children) => {
...component,
render: (_self) => {
<div>
<th>{ReasonReact.stringToElement(title)}</th>
</div>
}
};
我相信我需要map通过productRows,即List of ProductRow,具有以下功能:productRow => <td>productRow</td>。
在这个例子中我该怎么做?
或者,如果我完全不合时宜,请解释我如何实现上述目标。