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

Discussion on Spread Props #637

Open
jacobp100 opened this issue Nov 26, 2020 · 0 comments
Open

Discussion on Spread Props #637

jacobp100 opened this issue Nov 26, 2020 · 0 comments
Labels
ppx issues related to the reason-react ppx RFC

Comments

@jacobp100
Copy link

jacobp100 commented Nov 26, 2020

I wanted to open a discussion on a possible way forward to add spread props

If we required users to specify the type of the spread props (assume in the same file for now), it might be possible to have the PPX transform the following,

type exampleSpeadProps = {
  someProp: string,
  someOtherProp: string,
}

[@react.component]
let example = (~someComponentProp, [@react.rest] exampleSpreadProps) =>
  <div
    someComponentProp
    [@react.spead] exampleSpreadProps
  />

into

[@react.component]
let example = (~someComponentProp, ~someProp: string, ~someOtherProp: string) =>
  <div
    someComponentProp
    someProp
    someOtherProp
  />

This should preserve type safety and enable spreading

It'll also have the added benefit that you could use multiple rest/spread types (assuming no names overlap), and spread them to different child elements

It might also be possible to define the types in a different file if we leveraged some of the code from ppx-import

@davesnx davesnx added RFC ppx issues related to the reason-react ppx labels Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ppx issues related to the reason-react ppx RFC
Projects
None yet
Development

No branches or pull requests

2 participants