Skip to content

x-for trying to loop through a cleared object's keys #4231

Answered by ekwoka
domjanzsoo asked this question in 1. Help
Discussion options

You must be logged in to vote

Easy, just stop looping over keys.

Loop over entries.

<template x-for="[id, value] in Object.entries(selected)" :key="id">

In your above, your effects are using the key to access selected, but if selected changes, the key won't point to anything anymore, but the effect may still try to run before being cleaned up.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@domjanzsoo
Comment options

Answer selected by domjanzsoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants