-
Notifications
You must be signed in to change notification settings - Fork 178
Closed
Description
I created a small repro demo that I set up in two ways:
- using
[email protected]with[email protected] - using only
[email protected]with the preact standalone version of the module
Code:
//import { html, render } from 'https://cdn.jsdelivr.net/npm/[email protected]/preact/standalone.module.js';
//import { Fragment } from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/preact.module.js';
import { h, render, Fragment } from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/preact.module.js';
import htm from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/htm.module.js';
const html = htm.bind(h);
const elem = document.querySelector("#app");
const Item = (item) => {
return html`
<div key=${item.id} data-id=${item.id}>
${item.text}
</div>`;
};
const items = [{id: 1, text: 'one'}, { id: 2, text:'two' }];
const performRender = () => {
const children = items.map(item => html`<${Item} ...${item} />`);
render(html`<${Fragment}>${children.reverse()}<//>`, elem);
};
setTimeout(() => {
items.push({ id: 3, text: 'three'});
performRender();
}, 1000);
setTimeout(() => {
items.push({ id: 4, text: 'four'});
performRender();
}, 2000);
window.onload = performRender;Fiddle for reference: https://jsfiddle.net/0ukweoz1/2/
Results:
- when using preact with htm, the final version renders as:
four
three
two
one
- using htm preact standalone, the final version renders as:
four
three
two
one
one
note that also, the render after 1 second does not actually update the DOM, so three is never just added by itself
Metadata
Metadata
Assignees
Labels
No labels