无法为 react-contenteditable 创建 ReasonML 绑定

Can't create ReasonML bindings for react-contenteditable

我正在尝试为 react-contenteditablehttps://www.npmjs.com/package/react-contenteditable)创建一个小绑定,但 运行 出现运行时错误。

绑定如下:

[@bs.deriving abstract]
type eventTarget = {
  value: string,
};

[@bs.deriving abstract]
type changeEvent = {
  target: eventTarget,
};

[@bs.module "react-contenteditable"] [@react.component]
external make:
  (
    ~html: string,
    ~disabled: bool,
    ~onChange: changeEvent => unit=?,
  ) =>
  React.element =
  "ContentEditable";

和用法:

<ContentEditable
  html="text"
  disabled=false
  onChange={_ => ()}
 />

具体问题:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

最后一行应该是 React.element = "default"; 因为组件是库的直接导出,而不是它的成员。