Skip to content

React/JSX broken after external arity handling improvement #6880

Closed
@cknitt

Description

@cknitt

After #6874, I have the following problem:

module FormattedMessage = {
  @react.component @module("react-intl")
  external make: (~id: string, ~defaultMessage: string) => React.element = "FormattedMessage"
}

let _ = <FormattedMessage id="test" defaultMessage="Test" />

compiles to

JsxRuntime.jsx((function (prim) {
  return ReactIntl.FormattedMessage;
}), {
  id: "test",
  defaultMessage: "Test"
});

(which fails at runtime) instead of

JsxRuntime.jsx(ReactIntl.FormattedMessage, {
      id: "test",
      defaultMessage: "Test"
    });

I think the root cause is that React.component is not defined as an abstract type, but as 'props => React.element. @mununki tried to make it abstract in #6304, but hit a roadblock.

Although I am also asking myself why the compiler needs to introduce that extra function now that it knows that the external is a function of arity 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions