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

Remove the initial empty render of the scrollview if a scrollviewsize is passed #450

Merged
merged 18 commits into from
May 4, 2020

Conversation

arunreddy10
Copy link
Collaborator

@arunreddy10 arunreddy10 commented Jan 7, 2020

The current behavior of recyclerlistview is to render an empty scrollview and then wait for its on layout event to get its actual size before rendering all the children inside it. If an estimated scroll view size is passed, then the children can also be rendered in the first pass based on those estimates removing an initial blank render. To change the size after render, canChangeSize must be set to true.

@@ -91,6 +91,7 @@ export interface RecyclerListViewProps {
onVisibleIndicesChanged?: TOnItemStatusChanged;
renderFooter?: () => JSX.Element | JSX.Element[] | null;
externalScrollView?: { new(props: ScrollViewDefaultProps): BaseScrollView };
scrollViewSize?: Dimension;
Copy link
Collaborator

Choose a reason for hiding this comment

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

call out edge cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added in readme

@msvargas
Copy link

Please i need this, its posible merge?

@msvargas
Copy link

@arunreddy10 thanks, working perfectly :), now its full replacement for flatlist and sectionList

@@ -675,6 +717,11 @@ RecyclerListView.propTypes = {
//Specify the initial item index you want rendering to start from. Preferred over initialOffset if both are specified.
initialRenderIndex: PropTypes.number,

//Specify the estimated size of the recyclerlistview to render the list items in the first pass. If not provided, the recyclerlistview
//will first render with no items and then fill in the items based on the size given by its onLayout event. When provided, the items are
//rendered in the first pass according to the estimated size and then adjusted according to the actual size when the onLayout event arrives.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't true right? With the new changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the comments.

README.md Outdated
@@ -107,6 +107,7 @@ not be as fast.
| optimizeForInsertDeleteAnimations | No | boolean | Enables you to utilize layout animations better by unmounting removed items |
| style | No | object | To pass down style to inner ScrollView |
| scrollViewProps | No | object | For all props that need to be proxied to inner/external scrollview. Put them in an object and they'll be spread and passed down. |
| scrollViewSize | No | Dimension | Will prevent the initial empty render required to compute the size of the listview and use these dimensions to render list items in the first render itself. This is useful for cases such as server side rendering. |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mention how canChangeSize can help

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment for the same

@@ -391,7 +410,15 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
}
if (forceFullRender || this.props.layoutProvider !== newProps.layoutProvider || this.props.isHorizontal !== newProps.isHorizontal) {
//TODO:Talha use old layout manager
this._virtualRenderer.setLayoutManager(newProps.layoutProvider.newLayoutManager(this._layout, newProps.isHorizontal));
if (forceFullRender) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't what we want

Copy link
Collaborator

Choose a reason for hiding this comment

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

If layoutProvider and orientation changes we do the old thing. If only forceFullRender we use cached layouts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved forceFullRender to separate if condition

@naqvitalha naqvitalha closed this May 4, 2020
@naqvitalha naqvitalha reopened this May 4, 2020
@naqvitalha naqvitalha closed this May 4, 2020
@naqvitalha naqvitalha reopened this May 4, 2020
@arunreddy10 arunreddy10 merged commit e12e568 into master May 4, 2020
@naqvitalha naqvitalha deleted the removeInitialEmptyRender branch May 4, 2020 06:39
@cenaHara
Copy link

hi @naqvitalha , @arunreddy10 Why not merge request ?

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

Successfully merging this pull request may close these issues.

4 participants