Been loving 10.x.x thus far, thanks for all of your hard work! I did stumble on something today, however:
When a component renders two sibling elements (A which is dynamic and B which is static), preact produces DOM in the incorrect order if A renders null before later rendering content. I don't think it matters, but in case it does: the static sibling (B) does not have to be a component, i.e. you can replace <B /> with the literal <p>B</p> and the issue will still repro.
Some details:
- This issue does not repro on any 8.x.x version. It does repro on every 10.x.x version, including alphas and betas.
- I tested the dynamic component using both hooks and classes, and the issue occurs in both flavors.
/** @jsx h */
import { h, render } from "preact";
import { useState, useEffect } from "preact/hooks";
const A = () => {
const [show, setShow] = useState(false);
useEffect(() => {
setTimeout(() => setShow(true), 1000);
}, []);
// intentionally render <div> instead of <p> to ensure the root elements
// of both components are different, in case that changes any behavior.
// The issue of course repros even if a <p> is used.
return show ? <div>A</div> : null;
};
const B = () => <p>B</p>;
render(
<div>
<A />
<B />
</div>,
document.body
);
// Expected:
<div>
<div>A</div>
<p>B</p>
</div>
// Actual:
<div>
<p>B</p>
<div>A</div>
</div>
Link to sandboxes with minimal repro:
Been loving 10.x.x thus far, thanks for all of your hard work! I did stumble on something today, however:
When a component renders two sibling elements (A which is dynamic and B which is static), preact produces DOM in the incorrect order if A renders
nullbefore later rendering content. I don't think it matters, but in case it does: the static sibling (B) does not have to be a component, i.e. you can replace<B />with the literal<p>B</p>and the issue will still repro.Some details:
Link to sandboxes with minimal repro: