-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[VirtualizedSectionList] - Externalise and handle any sort of data blob #20787
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for doing this. I'll need to do some pretty extensive testing to make sure everything works before importing, but hopefully it won't take too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sahrens has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sahrens has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CircleCI failures look quite relevant too - can you fix those?
Thanks for the review @sahrens, I take a look on the test failure, and try to solve it! |
@sahrens From what I've read the flow errors due to
on the top of Props declaration. |
@sahrens I also try to implement basic test for |
I think exporting the flow types is a good way to go - gives much more control. Do you want to do that in this PR or separately? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, just a few more requested changes - sorry I didn't catch them in the first round.
And yes, thank you for adding the test :) |
@sahrens I made the changes, but not for the type of the props, I think it's better to be done in another PR, I try to implement it, but a lot of other errors comes out, like |
@sahrens My last commit as you request is ok for you ? :) |
@sahrens Any news on this ? |
The changes look good. I was about to merge this, but it looks like some conflicts need to be resolved first. Sorry for the trouble! |
@cpojer So I remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
// HeaderComponent?: ?ReactClass<any>, | ||
// onViewableItemsChanged?: ({viewableItems: Array<ViewToken>, changed: Array<ViewToken>}) => void, | ||
}; | ||
type SectionBase = Object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a regression. Could you work on putting back the proper Flow Type and running flow on the react-native repo to verify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SectionBase
type can't be specified, because it can handle different type of datas, like classic js object or Immutable object, by exemple the data type of VirtualizedList
is any
.
For SectionList
component SectionBase
can be specified because we know the data must be javascript object.
@@ -115,7 +91,8 @@ type OptionalProps<SectionT: SectionBase> = { | |||
*/ | |||
refreshing?: ?boolean, | |||
}; | |||
|
|||
/* $FlowFixMe - this Props seems to be missing a bunch of stuff. Remove this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fix this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really an expert with complex flow typing, I can try to remove this, but I'm not sure if I'm going to fix something of fix it in a good way :/
I think this looks good but I don't feel comfortable with relaxing the flow types. If you can fix that, I'm happy to land this PR. Overall, I think it would be great if we could change this API to use an iterator protocol, but I assume that is something to discuss later. |
@cpojer I answer in the comment above for the flow type :) For the iterator it's a good idea, that's should work very well for |
If you can rebase this PR, I can take a look at the flow types. |
@cpojer Thanks ! :) I update the branch to the current master and fix the conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
if (!sections) { | ||
return null; | ||
} | ||
let itemIdx = index - 1; | ||
for (let ii = 0; ii < sections.length; ii++) { | ||
if (itemIdx === -1 || itemIdx === sections[ii].data.length) { | ||
for (let ii = 0; ii < props.getItemCount(sections); ii++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working on this at FB. I think this is supposed to stay sections.length
here because sections
is always an array. I'm changing this internally, no need to do anything, just wanted to put this comment here for your information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer Thanks ! In fact it can be something else, by exemple if you use an immutable list, to get his length the method is size
and not length
so it's better to keep it outside to handle immutable data
Hey @magrinj, I'm about to land this change from FB's side after fixing up a few things. It seems that there were a bunch of bugs in the code that I fixed, among them the tests for I made a larger change to remove |
@cpojer Thanks a lot ! Sorry for the bugs, I didn't have time to test everything again between the different merges. I understand that you want to keep |
This pull request was successfully merged by @magrinj in 1946aee. When will my fix make it into a release? | Upcoming Releases |
Summary
Fixes #20770
Test Plan:
I test this class in my project with immutable datas, and it's perfectly working:
Changelog:
[General] [Changed] - Externalise and handle any sort of data blob
In this PR I externalise VirtualizedSectionList and make it working with any sort of data blob, so sections can be an Immutable Map by exemple.
I do this to follow the logic of VirtualizedList.
Hoping to have made the changes correctly!