Skip to content

External binding to component without @react.component #5725

Open
@mununki

Description

@mununki

https://forum.rescript-lang.org/t/call-for-help-2-test-jsx-v4/3781/22?u=moondaddi
As of JSX v4, the component can be written without @react.component. The issue came from the binding to the component with external.

type props<'msg> = {msg: 'msg}
@module("@foo/bar")
external make: props<_> => React.element = "SomeComponent"
// output
React.createElement((function (prim) {
                          return Bar.SomeComponent(prim);
                        }), {
                        msg: "!!!"
                      })

// expected
React.createElement(Bar.SomeComponent(prim), {
                        msg: "!!!"
                      })

The output after transformation @react.component is different from the above.

type props<'msg> = {
  msg: 'msg,
}
@module("@foo/bar")
external make: React.componentLike<props<string>, React.element> = "SomeComponent"

The generated js output gets different between componentLike<'props, element> and props<_> => React.element.

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