pmndrs / drei

🥉 useful helpers for react-three-fiber
https://drei.pmnd.rs/
MIT License
7.83k stars 642 forks source link

fix: Stats and StatsGl don't remove previous class names on rerender #1994

Closed lukehorvat closed 2 weeks ago

lukehorvat commented 2 weeks ago

Why

Both Stats and StatsGl don't remove class names set via the className prop on rerender. In the following example, if showStats is initially false and then later changes to true, the Hidden class does not get removed from the DOM element.

<Stats className={`Stats ${showStats ? '' : 'Hidden'}`} />

What

Fixed by removing the previously added class names during useEffect cleanup.

Checklist

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 14, 2024 9:35pm
codesandbox-ci[bot] commented 2 weeks ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

github-actions[bot] commented 2 weeks ago

:tada: This PR is included in version 9.107.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: