【发布时间】:2019-02-13 22:29:12
【问题描述】:
我正在着手进行理性反应。 在以下代码中:
let component = ReasonReact.statelessComponent("Component3");
let make = (~name, _children) => {
...component,
render: self => <input type_="checkbox" />,
};
我不明白第 3 行的 (...) 是什么意思。 当我删除它时,我收到一条错误消息:
The record field component can't be found.
If it's defined in another module or file, bring it into scope by:
- Annotating it with said module name: let baby = {MyModule.age: 3}
- Or specifying its type: let baby: MyModule.person = {age: 3}
【问题讨论】:
-
编辑:我已经看到“组件”默认实现了“渲染”方法。这种语法是否意味着“获取组件对象中的所有内容并在“渲染”功能上添加一些额外的功能?
-
这不是重复的,因为它不是 ES6 或 JSX,而是一种完全不同的语言,称为 Reason(它最初被正确标记为)。扩展语法在 Reason 中的用途与在 ES6 中(这是灵感的来源)中的用途相似,但并不完全相同,首先也是最重要的,因为它操作的是强的、名义上类型化的记录,而不是动态类型化的对象。
标签: syntax record reason reason-react