【问题标题】:How can I use react-datepicker in the ReScript app如何在 ReScript 应用程序中使用 react-datepicker
【发布时间】:2022-02-06 19:43:22
【问题描述】:

我正在尝试使用外部库,例如 react-datepicker。

我的代码和用法:

module DatePicker = {
  @react.component @module("react-datepicker")
  external make: () => React.element = "default";
}

@react.component
let make = () => {
  <DatePicker />
}

但是,我有一个错误:

未捕获的错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象。 检查...的渲染方法

附: 我尝试了这个答案Can't create ReasonML bindings for react-contenteditable 的解决方案,但它对我的错误没有帮助

【问题讨论】:

    标签: javascript reactjs reason rescript


    【解决方案1】:

    @scope 装饰器是一种解决方案

    module Dp = {
      @react.component @module("react-datepicker") @scope("default")
      external make: () => React.element = "default";
    }
    
    @react.component
    let make = () => {
      <Dp />
    }
    

    https://forum.rescript-lang.org/t/help-with-binding-currying/1540/11?u=grigoryev

    【讨论】:

      猜你喜欢
      • 2015-03-24
      • 2020-12-06
      • 2020-02-14
      • 1970-01-01
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      • 2018-10-08
      • 1970-01-01
      相关资源
      最近更新 更多