javascriptreactjsreasonrescript

How can I use react-datepicker in the ReScript app


I`m trying to use an external library such as react-datepicker.

My code and usage:

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

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

However, I`ve got an error:

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of ...

P.S.: I tried a solution from this answer Can't create ReasonML bindings for react-contenteditable but it doesn't help me with an error


Solution

  • @scope decorator is a solution

    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