computeConfigData is called when i scroll when everything is done loading... after analyzing all my code and how the different parts of the VirtualGrid component interact together, and your extensive knowledge on Vue.js and Javascript, how to fix without changing anything crucial ? The goal here is improve performance drastically, because the computed functions are be re-evaluated to no avail.
Assistant
The performance issue you're experiencing is due to unnecessary reactivity tracking in your computed properties. Specifically, you're referencing props inside your computed properties and the functions they call, which makes the reactivity system consider all of props as a dependency. This means any change to any part of props can cause your computed properties to re-evaluate, even if the changed part isn't directly related to what the computed property needs.
To fix this without changing anything crucial, you should avoid referencing props directly inside your computed properties and the functions they call. Instead, destructure the necessary properties from props at the top of your setup function. This way, Vue's reactivity system will only track the specific properties you actually depend on, avoiding unnecessary re-computations.
Here's how you can modify your code:
Destructure Props: Extract only the necessary properties from props at the top level of your setup function. This avoids referencing props inside computed properties.
Avoid Reactive Dependencies on Functions: Functions passed via props, such as getGridGap, can be mistakenly made reactive by Vue. To prevent this, you can wrap these default functions with markRaw.
This prevents Vue from making these functions reactive, so changes elsewhere in props won't cause them to trigger reactivity.
By making these changes, you ensure that your computed properties only depend on the values that should trigger re-computations. This eliminates unnecessary re-computations of computeConfigData and other computed properties when scrolling, significantly improving performance.
Summary:
Avoid referencing props inside computed properties and their helper functions: Destructure the needed properties from props to limit reactivity to only the necessary parts.
Wrap functions passed via props with markRaw: This prevents functions from being made reactive and causing unnecessary reactivity.
Following these steps will fix the performance issues without requiring significant changes to your component's logic.