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
Poor Keyed Each performance and Uncaught TypeError
#5006
Comments
Can you create a REPL to demonstrate the problem? |
This |
Sure, I'll try and get that working to provide an example.
Yes I have tried that, sorry I wasn't explicit in the initial post. That is what results in the poor performance (and my assumption about the looping). |
I'm getting the same error. I navigate to a specific page (
|
We would need an isolated reproduction to do anything about this issue. The error you are both listing usually relates to the dom being modified outside Svelte's control, and predictably, Svelte can't unmount things which no longer exist. Please create an isolated reproduction of the issue in the REPL so that we can see the issue you are encountering. |
FYI: As strange as it sounds, I believe a bad version of Chrome was giving me this same error just 5 minutes ago: #5290 (comment) I was scratching my head for two hours. I hadn't touched the project for three weeks, it worked when I left for vacation, now it didn't when I came back. I tried resetting everything, building everything from scratch, clearing all caches etc... Then I tried to reproduce the bug with Firefox, but couldn't. The same with Safari, Brave etc... When I updated Chrome to latest, the bug disappeared. |
Closing due to inactivity and because no reproducible was given. |
Honestly not sure if this is still a bug or some piece of logic that I'm not understanding but I'm stuck between a rock and a hard place! Also, apologies for the long post but I wanted to get as much detail in here as possible.
Versions
Premable setup
I have a large (5000+ item) array that I have filtering functionality for through standard JS array filtering etc. The rendering of the items is a non-issue as I have conditional scroll logic.
I am try to conditionally show a simple
i
tag within a custom component that is being used to render each item.For example, I have the following block in my
Item
component:Nothing too complex. (Note, the filtering works fine without this if/else block).
I then have my iteration over the array of items through the following:
The Problem
If I add in the if/else block, then I receive the following error when I try to filter the array:
The research that I have done mostly leads to information relating to Sapper etc. but I am not using that here. The one fix that I found that does work is from here which involves changing code within
node_modules
and I'm not wanting to do that - at least not for the time being.The thought I had following this error was that Svelte wasn't able to work out which child should be removed from the view when it runs
detach
so I tried a few various keys including the fullitem
object, and an individual key string added to each item itself.This fixes the initial error that I was seeing, however the performance for filtering the array itself is very bad. With keypress events (which I use for filtering) taking nearly half a second each.
I'm guessing this is due to Svelte having to iterate over the array each time to work out what needs to be removed based on the keys, but I'm wondering if there is a simpler solution that I could employ.
Any information on this would be absolutely fantastic. More than happy to provide more information if it's needed.
Thanks!
The text was updated successfully, but these errors were encountered: