fix: React Strict Mode white board bug (texture disposal)#718
Open
kdhoon723 wants to merge 1 commit intotscircuit:mainfrom
Open
fix: React Strict Mode white board bug (texture disposal)#718kdhoon723 wants to merge 1 commit intotscircuit:mainfrom
kdhoon723 wants to merge 1 commit intotscircuit:mainfrom
Conversation
… Mode white board bug The BoardMeshes component previously received pre-built meshes via useMemo. The useEffect cleanup mutated these shared objects (setting material.map = null), so when React Strict Mode re-mounted, the second mount reused meshes with destroyed textures, rendering a white board. Now each useEffect creates its own mesh instances internally, so cleanup only disposes resources owned by that specific effect invocation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| if (!rootObject || !geoms) return | ||
|
|
||
| geometryMeshes.forEach((mesh) => { | ||
| const meshes = createGeometryMeshes(geoms) |
Contributor
There was a problem hiding this comment.
Missing import for createGeometryMeshes function
The function createGeometryMeshes() is called but never imported. Only createTextureMeshes is imported from "./textures" (line 14). This will cause a runtime error:
ReferenceError: createGeometryMeshes is not defined
Fix: Add the import alongside the existing createTextureMeshes import:
import { createTextureMeshes, createGeometryMeshes } from "./textures"Or import from the appropriate module where createGeometryMeshes is defined.
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BoardMeshescomponentuseMemo-created meshes were mutated byuseEffectcleanup (material.map = null), so the second mount reused destroyed texturesuseMemointouseEffectbodies so each mount owns its own mesh instancesdisposeMeshhelper (no longer needed)Changes
BoardMeshesnow receives raw data props (geoms,textures,boardData,pcbThickness,isFauxBoard) instead of pre-builtTHREE.Mesh[]arraysuseEffectcallscreateGeometryMeshes()/createTextureMeshes()internallygeoms, CanvasTexture fromtextures)useMemohooks fromCadViewerManifoldthat previously created meshesTest plan
🤖 Generated with Claude Code