perf(effects): optimize GradientBlinds loop
- Replace immutable refs with mutable objects for pointer tracking to reduce GC pressure - Remove synchronous getBoundingClientRect from animation loop to prevent layout thrashing - Ensure mouse coordinates are updated efficiently without re-allocating arrays Co-authored-by: ragusa-it <196988693+ragusa-it@users.noreply.github.com>
This commit is contained in:
@@ -8,3 +8,7 @@
|
||||
## 2024-05-22 - High-Frequency State Isolation
|
||||
**Learning:** High-frequency state updates (like typing effects) in large parent components (`Hero`) trigger massive unnecessary re-renders of expensive sub-trees (`GradientBlinds`, `Button`).
|
||||
**Action:** Isolate high-frequency state into small, leaf-node components (e.g., `TypedText`) and wrap them in `React.memo` if necessary, keeping the heavy parent static.
|
||||
|
||||
## 2025-01-26 - WebGL Layout Thrashing
|
||||
**Learning:** WebGL animation loops often contain fallback paths (e.g., `if (!rect) rect = getBoundingClientRect()`) that trigger synchronous layout thrashing every frame if the primary path fails or initializes late.
|
||||
**Action:** Remove synchronous layout reads from `requestAnimationFrame` loops. Use `ResizeObserver` to cache dimensions and handle the "not ready" state by skipping updates or using safe defaults (0,0) instead of forcing a reflow.
|
||||
|
||||
Reference in New Issue
Block a user