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

Fix FlatList ItemSeparatorComponent type #36175

Closed
wants to merge 2 commits into from
Closed

Fix FlatList ItemSeparatorComponent type #36175

wants to merge 2 commits into from

Conversation

bigcupcoffee
Copy link
Contributor

Summary

FlatList's ItemSeparatorComponent type did not support passing in react element as per documented in docs.

Changelog

[GENERAL] [FIXED] - Fix FlatList ItemSeparatorComponent type

Test Plan

None needed

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 15, 2023
@bigcupcoffee
Copy link
Contributor Author

Welp from what I see in the code VirtualizedSectionList actually does not support react element as ItemSeparatorComponent, yet it's documented as supported? Do I make it support it or...

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,482,874 -2,842
android hermes armeabi-v7a 7,803,849 -2,674
android hermes x86 8,959,792 -3,102
android hermes x86_64 8,817,172 -2,728
android jsc arm64-v8a 9,116,966 +2,417,516
android jsc armeabi-v7a 8,313,038 +822,057
android jsc x86 9,168,369 -55,664
android jsc x86_64 9,427,203 +2,502,537

Base commit: cb28a2c
Branch: main

@NickGerleman
Copy link
Contributor

Welp from what I see in the code VirtualizedSectionList actually does not support react element as ItemSeparatorComponent, yet it's documented as supported? Do I make it support it or...

Does it work for FlatList, but not VirtualizedSectionList? It is does work for FlatList, but only FlatList, we could put this in FlatList typings instead of VirtualizedList typings.

@bigcupcoffee
Copy link
Contributor Author

bigcupcoffee commented Feb 16, 2023

@NickGerleman I believe problem is VirtualizedSectionList does not properly override VirtualizedList's ItemSeparatorComponent type, and thus this.props.ItemSeparatorComponent comes in as possible Element which it should not be according to both code and the type override attempt (probably not I'm just very lost in all the code atm) here. Worth noting that SectionList docs actually state Element is supported as well, so we either support element in section list, or fix the type override and edit docs?

@bigcupcoffee
Copy link
Contributor Author

@NickGerleman hey, would this get any attention? I'm glad to modify the PR as long as I know what would be the best fit here

@yungsters
Copy link
Contributor

Thanks for the contribution, @bigcupcoffee!

It looks like support for elements was added in #32748.

However, there are Flow type errors surfaced by Circle CI. Can you look into fixing those? I can merge this after the errors addressed.

@yungsters
Copy link
Contributor

Also, I apologize for the delay in reviewing this. (For some reason, our internal tooling that helps surface PRs was not working correctly.)

@yungsters yungsters self-requested a review June 1, 2023 15:34
Copy link
Contributor

@yungsters yungsters left a comment

Choose a reason for hiding this comment

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

Requesting changes due to Flow errors in Circle CI.

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 20, 2023
@bigcupcoffee
Copy link
Contributor Author

@yungsters I'm not sure how to fix the SectionList flow error, there seems to be an override already here, which should mark the prop as Component only (since VirtualizedSectionList due to its own separator implementation doesn't support Element as for now, this code). I guess it comes from the info.section.ItemSeparatorComponent || this.props.ItemSeparatorComponent and one of these end up having Element as a possible type. I'm not good with flow so not sure how to resolve that, would really use some help here. While for VirtualizedList error, if I'm correct, you just need to add support for React.Element right here and that should fix it.

Awaiting your reply about SectionList, as once again, docs state that Element is supported, so that should be fixed too?

Copy link

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 17, 2024
Copy link

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants