drei icon indicating copy to clipboard operation
drei copied to clipboard

<Segment/> does not unmount.

Open daralthus opened this issue 2 years ago • 1 comments

  • three version: 9.4.5
  • @react-three/fiber version: 8.0.14
  • @react-three/drei version: 9.11.0
  • node version: 16.15.0
  • yarn version: 1.22.19

Problem description:

<Segments>{cond && <Segment />}</Segments> does not remove children.

Relevant code:

Play around with the count slider and notice that lines don't disappear and are not spread evenly anymore. https://codesandbox.io/s/segment-bug-jtxvp6?file=/src/App.js

daralthus avatar May 31 '22 18:05 daralthus

I'm not sure this WASN'T happening before, but in any case you can solve it by keying the segments with the count

<Segments  key={config.count} 

So that the data is recreated when count changes - which should be the case. Ideally the count shouldn't change at runtime since it requires recreating the geometry in most use cases.

gsimone avatar Jun 01 '22 08:06 gsimone