You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
Hello @david-swift
I found strange issue with List, the Item is duplicated
To Reproduce
I want get "load more" functionality,
after load next portion of content i modify list like this:
@Statevaritems:[Item]=[]func loadMore(){// fetch and decode hereIdle{varitems=self.items
letloadMoreIndex= items.lastIndex(where:{ $0.id =="load-more"})! // ! for simplify construction here self.items.insert(contentsOf: fetchedItems, at: loadMoreIndex)// for insert at the end but before load more item}}
Current behavior:
items contains one object with id "load-more"
list contains two view with text "Load more..."
Expected behavior
items contains one object with id "load-more"
list contains one view with text "Load more..."
Additional context
No response
The text was updated successfully, but these errors were encountered:
I'm not able to reproduce this and it looks like unexpected behavior, so I'd be very happy if you could provide more details about the situation it occured.
As far as I understand your idea, what you're trying to accomplish could be accomplished in a cleaner way using a computed property combined with the state property:
@Stateprivatevaritems:[Item]=[]varallItems:[Item]{
items +[id:"load-more")]}varview:Body{List(allItems){ item in
switch item.id {
case "load-more":// Load more view
default:
// Other views}}}func loadMore(){// ...
items += fetchedItems
// ...}
It may help looking at #37 (comment) for more information about state. In general, if state management is complex, there's probably a simpler, more elegant solution. You can always open a discussion if you have questions! And I'll definitely improve the docs to mention those concepts at some point.
Describe the bug
Hello @david-swift
I found strange issue with List, the Item is duplicated
To Reproduce
I want get "load more" functionality,
after load next portion of content i modify list like this:
Current behavior:
Expected behavior
Additional context
No response
The text was updated successfully, but these errors were encountered: