无法为Reaction-Content Editable创建ReasonML绑定绑定、Content、Reaction、ReasonML

2023-09-04 02:23:35 作者:都她妈的瞎

我正在尝试为react-contenteditable(https://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";
原本是看不起VR游戏 现在EA要建VR团队

和用法:

<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";,因为该组件是库的直接导出库,而不是库的成员。