|
The HWS article How to fix slow List updates in SwiftUI explains how to fix an issue with lists updating slowly. The example below is given, which demonstrates a large
The fix, as explained in the article, is to add
Adding |
|
Good question for why it is not happening btw. Logically it should work as well, as it actually generates new UUID meaning the view should refresh without delay as well. Seems like processed in a different way than List without it. But from practical point of view, would you ever need sectioned list with thousands rows in it? ))) I doubt... the purpose of sections to visually separate rows on a screen. If you need to scroll such long list you won't be able to see what section you are currently in... so... |
|
Thanks for the reply @ygeras! My use case is displaying search results with a separate (small) section above showing the search parameters (this is the app I'm working on, the fourth screenshot showing the results screen is the view I'm having this issue with). I'd appreciate any suggestions for fixes or alternatives! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
But what is your issue there? In Pauls example you are "regenerating" huge amount of rows while shuffling them. When you attached UUID to List it basically says: hey swiftui, the the whole list is different so refresh the list as the whole, no need to go inside and check which row is different and regenerate it. And with huge amount of rows it is a lot of work to do. With search you're filtering your data, which in turn provides you less rows that match your query. Do you experience delays while doing search or what is the issue? |
|
The 'search' being performed isn't related to this list or to this view. It occurs elsewhere in the app and, once complete, the results are passed to this view. I do not actually need to regenerate the list once it is created, but there are already significant delays when the list is created. Removing the sectionning and adding the id trick solves these, but I need a way to acheive this without losing the sections. |
|
I think I understood what was the problem. You don't need to touch the uppers sections in your view? If it only applied to bottom section. You can probably do like so:
You need to put List inside Section and not Section inside a List |
|
Thanks for the suggestion! That indeed works, but then the problem is how to combine that with another section (otherwise the use of section is redundant). Are you suggesting something like this below?
Unfortunately, when placing your code inside a |
|
|
|
This also works and if you add UUID to Vstack
|
|
Out-of-the-box idea: have you thought about:
|
|
I suspect your real |
|
Thank you all for your suggestions! They're great ideas, but having tried them all sadly I don't think any solve the issue. I have however found a workaround to avoid running into this problem in the first place, so I'll mark this as solved. Thank you all! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.