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

Rows disappear when changing LayoutProvider #738

Closed
davidmalis opened this issue Aug 3, 2022 · 7 comments
Closed

Rows disappear when changing LayoutProvider #738

davidmalis opened this issue Aug 3, 2022 · 7 comments

Comments

@davidmalis
Copy link

davidmalis commented Aug 3, 2022

I am using version 4.1.1 and trying to implement a RecyclerListView with a List/Grid view switch (as mentioned in the comment of LayoutProvider).
I'm NOT using forceNonDeterministicRendering because all my items have a well known dimensions, specified in the LayoutProvider per view type.

The two LayoutProviders for List and Grid view are working as expected.

However, when trying to implement a switch which toggles the LayoutProvider, the items which are rendered currently on screen disappear. When I keep toggling, the items keep disappearing.

Let's say I have 100 rows, 15 of them are rendered (with renderAheadOffset in mind). I then replace the LayoutProvider, the first 15 items disappear, the 16th, 17th an the rest are now at the start of the scroll view. If I replace the LayoutProvider again, then the next 15 items will disappear and so on.

I tried to dig something that would help me in the ViewRenderer and I was able to find out that the items that seemingly disappear actually have a width and height dimension set to 0. I tracked where this change of dimension is coming from using DebugHandlers and got to this commit which was made 4 months ago: #705

If I remove the _forceSizeUpdate call from the lib, toggling the List/Grid view works as expected, and items don't disappear, however I'm not sure if this breaks anything else.

I kindly ask if you could check it. Thx.

edit: Using v3.0.5 works as expected. This version does not include the #705.

@kevin-kp
Copy link
Contributor

kevin-kp commented Aug 3, 2022

Hi @davidmalis

This is something that is fixed in #734
However, @naqvitalha still needs to merge this PR.

@naqvitalha
Copy link
Collaborator

I'm looking into this. Thanks for raising this issue.

@naqvitalha
Copy link
Collaborator

I've pushed 4.1.3 with @kevin-kp 's fix. This should work fine now.

@timothymiller
Copy link

This issue persists with v4.1.3

How to reproduce:
The first layout provider change works. The second and subsequent changes do not.

@davidmalis
Copy link
Author

davidmalis commented Aug 30, 2022

I can confirm that it works for me with v4.1.3

@timothymiller
Copy link

@davidmalis Are you using a hooks or class based approach?

I am using hooks and it does not. I can provide a code example. It does seem hooks are not officially supported.

@davidmalis
Copy link
Author

davidmalis commented Aug 30, 2022

@timothymiller I'm using hooks, something along the lines of this:

In my Redux store I have a flag for layout which can be 'grid' or 'list', and on my screen I have a button which toggles this flag in store.

When the flag is toggled, the component in which I render RecyclerListView, re-renders and the RecyclerListView is provided with a new DataProvider and LayoutProvider instance (I don't have LayoutProvider in component's state).

LayoutProvider, of course, has different logic depending on the before-mentioned flag.

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

No branches or pull requests

4 participants