Refactor /sketcher page#2140
Conversation
| previewSketch.current?.teardown(); | ||
| p5?.remove(); | ||
| }; | ||
| }, [initialModalState?.curves]); |
There was a problem hiding this comment.
This UE dependency is the one thing I am completely lost on. It seems to me that the intention was for setting sketch.state (i.e. previewSketch.current.state here) to automatically update the previewRef canvas and everything to just work; with this approach, we'd only ever need to run this UE once, and only adjust sketch.state to edit the preview.
However. This simply doesn't seem to be working. The only way I can get the preview to update is if I insert initialCurves: initialModalState?.curves into the makeGraphSketcher (which shouldn't need to be there because the graph always initialises from empty on this page), and rerun this UE after the modal closes with this extra dependency. I really don't understand how the sketcher question page works without doing this...
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2140 +/- ##
==========================================
- Coverage 43.75% 43.75% -0.01%
==========================================
Files 593 593
Lines 25033 25035 +2
Branches 8316 8292 -24
==========================================
Hits 10954 10954
+ Misses 14029 14024 -5
- Partials 50 57 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Refactors the /sketcher page to make better use of React objects.
previewSketch) and that were not updating correctly and used in UE dependencies wrong, are now refs.closeModal. Good React style should (although we are fairly bad at this) avoid chaineduseEffects(i.e. one runs asetX, andXis a dependency in a second UE). I've tried to push everything into happening once, when the modal shuts.makeGraphSketcherfunction, so the canvas is no longer duplicated locally.I don't really want to take this out of draft until I understand the comment below 😔