Description
I attempted to set up a code sandbox here: https://codesandbox.io/p/github/talkingtab/gitbox/main?import=true
Let me know if I need to do something to it. I am a codesandbox newbie.
This is a visualization of recursive treemaps of a file system directory where a box usually is a directory. clicking a directory box will transform then show a box with the treemap of the selected directory.
The problem is the line below key={i}
. When this used, the geometry is messed up after clicking. I was trying to search for a possible cause and discovered question #533. To test if the key is the source of the problem, I replaced
key={i}
with
key={r.boxid}
where the boxid is unique, whereas the index is not. On my home machine this solves the problem, as it does in the code sandbox.
return (
<mesh onContextMenu={onContext}>
{boxes.map((r, i) => {
let tindex = r.tindex ? r.tindex : r.boxid % 15;
return (
<BoxArea
key={i}
ref={(el) => addRef(el, i)}
r={r}
onEffect={() => {
console.log("calling next state %s", boxstate);
action("faded");
}}
onClick={(e) => onClick(e, r, i)}
tex={btextures[tindex]}
tex2={plain}
/>
);
})}
</mesh>
);