Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

JSX v4 shared props #699

Merged
merged 2 commits into from Oct 25, 2022
Merged

JSX v4 shared props #699

merged 2 commits into from Oct 25, 2022

Conversation

mununki
Copy link
Member

@mununki mununki commented Oct 25, 2022

This PR adds a new feature for JSX v4 which is using shared props type as an argument of @react.component
#695

Example

type sharedProps<'a> = {x: 'a, y: string}

// original
module V4C2 = {
  @react.component(:sharedProps<'a>) // <- here
  let make = (~x, ~y) => React.string(x ++ y)
}

// converted to
module V4C2 = {
  type props<'a> = sharedProps<'a>

  @react.component(: sharedProps<'a>) let make = ({x, y, _}: props<'a>) => React.string(x ++ y)
  let make = {
    let \"SharedProps$V4C2" = (props: props<_>) => make(props)

    \"SharedProps$V4C2"
  }
}

@mununki mununki changed the title Shared props JSX v4 shared props Oct 25, 2022
@cknitt
Copy link
Member

cknitt commented Oct 25, 2022

Great work! Thanks a lot! 🎉

All the tests have sharedProps<'a> with a single type parameter. Maybe also add a test with no type parameter and a test with more than one.

@mununki
Copy link
Member Author

mununki commented Oct 25, 2022

Great work! Thanks a lot! 🎉

All the tests have sharedProps<'a> with a single type parameter. Maybe also add a test with no type parameter and a test with more than one.

Good point. Added e39c867

@mununki mununki merged commit 22776fd into master Oct 25, 2022
@mununki mununki deleted the shared-props branch October 25, 2022 17:35
@mununki
Copy link
Member Author

mununki commented Oct 25, 2022

Sorry, every time I forgot the changelog. I’ll add it on another PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants