Skip to content

Make usage of _ in object keys consistent between external and JSX #4348

Closed
@alex35mil

Description

@alex35mil

JSX:

<button type_="button" />

Compiles to:

var React = require("react");

React.createElement("button", {
      type: "button"
    });

external:

type t;

[@bs.obj] external make: (~_type: string) => t = "";

let x = make(~_type="x");

Compiles to:

var x = {
  type: "x"
};

But when bindings to React components meet external, it's required to use prefix form:

module X = {
  [@react.component] [@bs.module "x"]
  external make: (~_type: string) => React.element = "X";
};

So on the call site it's:

<button type_="button" />
<X _type="x" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleOld issues that went stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions