我有一个非常紧凑的 ReasonReact reducer 组件,它有一个组件,initialState,reducer,action,render 函数如下:
type actions =
| DoNothing;
let component = ReasonReact.reducerComponent("ShowHide");
let make = (~name, _children) => {
...component,
initialState: () => 0, /* here, state is an `int` */
reducer: (action, state) =>
switch action {
| DoNothing => ReasonReact.NoUpdate;
},
render: (self) => {
let greeting =
"Hello: " ++ name ++ ". You've clicked the button " ++ string_of_int(self.state) ++ " time(s)!";
<div></div>
}
};
我正在尝试使用以下ReactDOMRe.renderToElementWithId
函数在我的 app.re 文件中呈现:
<div id = "RenderShowHide"></div>
ReactDOMRe.renderToElementWithId(<ShowHide name="hello" />, "RenderShowHide")
但是,Reason/Bucklescript 编译器抱怨如下:
This has type:
(ReasonReact.reactElement, string) => unit
But somewhere wanted:
at <anonymous>actElement
但是,我很难理解 actElement 是什么。任何关于 actElement 是什么以及我如何解决上述问题的建议都将不胜感激。谢谢你。