-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Test case:
import { html, signal } from './uhtml.js';
const items = signal([]);
const ListItem = ({item}) =>
html`<li>${item.text}</li>`;
const List = ({items}) =>
html`<ul>
${items.value.map((item) =>
html`<${ListItem} item=${item} />`
)}
</ul>`;
document.body.append(
html`<${List} items=${items} />`
);
for (let i = 0; i < 3; i++) {
items.value = [...items.value, ({text: `item ${i}`})];
}
The loop errors on the 3rd iteration:
Uncaught TypeError: can't access property "text", item is undefined
If I inline the li into List instead of a separate function, no error.
If I don't wrap the item in an object, and items is an array of strings, no error.
If I use the component fn directly instead of a nested tagged template, no error, eg:
${items.value.map(item => ListItem({item}))}
Metadata
Metadata
Assignees
Labels
No labels