-1

以前,我是[@bs.as "in"]这样使用的。

[@bs.deriving abstract]
type cssTransitionProps = {
  [@bs.as "in"]
  _in: bool,
  timeout: int,
  classNames: string,
};

我怎么能在这里做类似的事情?

module CSSTransition = {
  [@bs.module "react-transition-group"] [@react.component]
  external make:
    (
      ~_in: bool,
      ~timeout: int,
      ~classNames: string,
      ~children: React.element
    ) =>
    React.element =
    "CSSTransition";
};
4

1 回答 1

2

您不必做任何事情,bucklescript 会为您完成。

如果您查看 js 输出,您会看到它_in被转换为in

return React.createElement(ReactTransitionGroup.CSSTransition, {
              in: match$2[0],
              timeout: 200,
              classNames: "my-node",
              children: React.createElement("div", undefined, React.createElement(CommandsArea.make, {
                        text: text,
                        setText: match[1]
                      }), React.createElement(Toolbar.make, {
                        result: match$1[0]
                      }))
            });
于 2019-07-09T01:33:19.327 回答