Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React PPX v4 no longer drops leading underscore from prop name #5908

Closed
Minnozz opened this issue Dec 14, 2022 · 7 comments
Closed

React PPX v4 no longer drops leading underscore from prop name #5908

Minnozz opened this issue Dec 14, 2022 · 7 comments
Labels
stale Old issues that went stale

Comments

@Minnozz
Copy link
Contributor

Minnozz commented Dec 14, 2022

In previous versions of ReScript / the React PPX, I used the following bindings:

module Chart = {
   @module("react-chartjs-2") @react.component
   external make: (~_type: ChartType.t, ~data: {..}, ~options: {..}) => React.element = "Chart"
 }

The leading underscore from ~_type was dropped to bind to the prop type.

In the new React PPX, this underscore is no longer dropped, which makes the binding not work.

@Minnozz
Copy link
Contributor Author

Minnozz commented Dec 14, 2022

I believe this is related to #5904, but maybe this change should be mentioned separately in the changelog.

@shulhi
Copy link
Member

shulhi commented Dec 15, 2022

I have the same issue, as a workaround, I did something like this – use an intermediate type as the prop (@as) working fine here.

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

  type props<'a> = {
    @as("id") id_: string,
    defaultMessage: string,
    tagName?: string,
    values?: {..} as 'a,
  }

  let make = (props: props<'a>) =>
    <Internal
      id={props.id_}
      defaultMessage={props.defaultMessage}
      tagName=?{props.tagName}
      values=?{props.values}
    />
}

@mununki
Copy link
Member

mununki commented Dec 15, 2022

@Minnozz Good catch!
I've updated the changelog in the following PR #5905 Thank you for suggestion.

@mununki
Copy link
Member

mununki commented Dec 15, 2022

Changelog 1964938

@mununki
Copy link
Member

mununki commented Dec 15, 2022

@shulhi That would be a good workaround without @react.component until the PR is merged. Thanks!

@cknitt
Copy link
Member

cknitt commented Dec 17, 2022

Another option is to use ~\"type": ChartType.t.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Old issues that went stale label Sep 26, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Old issues that went stale
Projects
None yet
Development

No branches or pull requests

4 participants