编译时无法找到错误'变体构造函数'

时间:2018-05-09 11:51:25

标签: reason bucklescript reason-react

我正在尝试在ReasonReact项目上使用可排序的列表组件react-sortable-hoc。但是我遇到了一个错误,我试图弄清楚几个小时。

我遵循的步骤:

  • 为模块.positionr { display: flex; align-items: center; }
  • 制作了sortableContainer()sortableElement()的@bs绑定
  • 伪造两个函数返回的reactClass并将其放在文件react-sortable-hocSortableContainer.js
  • 制作另一个名为Todolist的React组件,它使用组件SortableContainer,而SortableContainer使用组件SortableElement。

代码段


/* SortableContainer.re */

[@bs.val] [@bs.module "react-sortable-hoc"] external sortableContainer : 'a =>
ReasonReact.reactClass = "";

let sortableContainerReactClass: ReasonReact.reactClass = sortableContainer(() => {
  
    (ReasonReact.createElement(SortableElement))
}); let make = (children) => ReasonReact.wrapJsForReason( ~reactClass=sortableContainerReactClass, ~props = { "onSortEnd": () => {} }, children );
/* SortableElement.re */

[@bs.val] [@bs.module "react-sortable-hoc"] external sortableElement : 'a => 
ReasonReact.reactClass = "";

let sortableElementReactClass: ReasonReact.reactClass = sortableElement(() => {
  
  • (ReasonReact.stringToElement("testing is good"))
  • }); let make = (children) => ReasonReact.wrapJsForReason( ~reactClass=sortableElementReactClass, ~props = { "onSortEnd": () => {} }, children );
    /* List.re */
    
    let component = ReasonReact.statelessComponent("List");
    
    
    let make = (~items=[||], _children) => {
      {
        ...component,
        render: (_self) => {
          
            
          
        }
      }
    };
    
    

    编译此代码时,我收到此错误。

    # ERROR
    
    We've found a bug for you!
      /Users/jaisonjustus/code/todotabre/src/components/SortableContainer.re 5:34-48
    
      3 │
      4 │ let sortableContainerReactClass: ReasonReact.reactClass = sortableConta
          iner(() => {
      5 │   
      (ReasonReact.createElement(SortableElement))
    6 │ }); 7 │ The variant constructor SortableElement can't be found. - If it's defined in another module or file, bring it into scope by: - Annotating it with said module name: let food = MyModule.Apple - Or specifying its type: let food: MyModule.fruit = Apple - Constructors and modules are both capitalized. Did you want the latter? Then instead of let foo = Bar, try module Foo = Bar.

    此代码有什么问题?

    0 个答案:

    没有答案