qwik: [π]Store array update does not rerender list
Which component is affected?
Qwik Runtime
Describe the bug
There is a problem with rendering updated values using list { store.array.map } I can change values only one or twice, depending on code usage after that any further modification is not updating values visually, however store values are changed Iβve created thread on discord https://discord.com/channels/842438759945601056/1191080926554361992 I managed to find a solution and itβs working but it should be used this way
As you can see on the image store.values are different than those that are visible using .map
As i mentioned earlier 1 or 2 operations are displayed any further only updates store values but not items rendered via { store.array.map }
IMPORTANT: This code is working in stackblitz https://stackblitz.com/edit/qwik-starter-kzdpd9 (version 1.2.11)
Reproduction
Steps to reproduce
Here are different ways to modify store.arrays: // Not working #1 (can modify 1 element) const category: PartCategoryData = { id: id.value, name: name.value }
store.categories.forEach((c, index) => {
if (c.id === category.id)
store.categories[index] = category;
});
// Not working #2 (can modify 1 element)
store.categories = store.categories.map((category) => {
if (category.id === id.value) {
return {
...category, name: name.value
};
}
return category;
});
// Not working #3 (can modify 1 element)
const modified = store.categories.map((category) => {
if (category.id === id.value) {
return {
...category, name: name.value
};
}
return category;
});
store.categories.splice(0, store.categories.length, ...modified);
// Not working #4 (can modify 2 elements)
const selectedCategory = store.categories.find(category => category.id === id.value)
if (selectedCategory) {
selectedCategory.name = name.value;
}
// Not working #5 (can modify 2 elements)
store.categories.forEach(category => {
if (category.id === id.value) {
category.name = name.value;
}
});
// Not working #6 (can modify 2 elements)
for (const category of store.categories) {
if (category.id === id.value) {
category.name = name.value;
break; // If you only want to modify the first matching item
}
}
// Not working #7 (can modify 1 element)
store.categories = store.categories
.filter(category => !(category.id === id.value))
.concat(store.categories.filter(category => category.id === id.value)
.map(category => ({ ...category, name: name.value }))
);
System Info
Windows 11, Opera browser, mozilla, edge
In my project im using Qwik ^1.2.15
Additional Information
You can find more on discord thread https://discord.com/channels/842438759945601056/1191080926554361992
About this issue
- Original URL
- State: open
- Created 6 months ago
- Comments: 23 (2 by maintainers)
Commits related to this issue
- test: add test for #5662 issue — committed to gioboa/qwik by gioboa 4 months ago
- test(v2): add test for #5662 issue (#5959) — committed to QwikDev/qwik by gioboa 4 months ago
Great news! π
I did some test on qwik@1.2.11 and itβs not working there. So only in Stackblitz with qwik 1.2.11 itβs working, might it be environment issue?