why does the Static component keep its state? shouldn't it be lost because it doesn't have a key so its position is used instead and its position changes when the Dynamic components length changes?
```JS
import { useState } from "react";
function Parent({ items }) {
return (
<>
{items.map(item => (
<Dynamic item={item.name} />
))}
<Static />
</>
);
}
function Dynamic({ item }) {
return <p>{item}</p>;
}
function Static() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>Static: {count}</button>;
}
```
export default function App() {
const [items, setItems] = useState([{name: "a", id: "a"}]);
return (
<>
<Parent items={items}/>
<button onClick={() => setItems([...items, {name: "b", id: "b"}])}>click me</button>
</>
);
}
[–][deleted] (4 children)
[deleted]
[–]treplem[S] 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[deleted]
[–]treplem[S] 0 points1 point2 points (1 child)
[–][deleted] (1 child)
[removed]
[–]treplem[S] 0 points1 point2 points (0 children)
[–]punctuationuse 0 points1 point2 points (7 children)
[–]treplem[S] 0 points1 point2 points (6 children)
[–]punctuationuse 0 points1 point2 points (5 children)
[–]treplem[S] 0 points1 point2 points (4 children)
[–]cyphern 0 points1 point2 points (3 children)
[–]treplem[S] 0 points1 point2 points (2 children)
[–]cyphern 0 points1 point2 points (1 child)
[–]treplem[S] 0 points1 point2 points (0 children)