Add constructor for section type in VirtualizedSectionList by sgny · Pull Request #614 · rescript-react-native/rescript-react-native

@sgny

Should close #605

Notes on implementation:

  • section needs to be consumed as well as constructed, therefore I added a constructor after the type definition. This works without any issues, as tested for this case but also from prior experience.
  • To avoid confusion with extraData, I chose the name moreFields.
  • If the additional key moreFields was another parameter ('moreFields), then section would need to be typed as section('item, 'moreFields) which necessitates specifying 'moreFields when creating section - if the key is not used. To avoid such unnecessary complexity, I chose to define a moreFields type instead and added a function to cast anything as that type.

@sgny sgny mentioned this pull request

Sep 22, 2019

MoOx

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I would just find a more explicit name for moreFields, maybe something like additionalSectionData or just additionalData

@sgny

@sgny

Since additional fields will be useful only for data relevant to the section (such as title as in the example given in #605), I thought sectionData might be a better name. What do you think @MoOx ?

I also remembered to update documentation

MoOx

MoOx approved these changes Sep 26, 2019

@MoOx

cknitt

@MoOx MoOx deleted the sectionList branch

September 26, 2019 10:34

@sgny sgny mentioned this pull request

Oct 12, 2019