0 day streak
javascript / intermediate
Snippet

Performance Optimization for Large Objects with markRaw

markRaw explicitly marks an object so that it will never be converted into a proxy. This is crucial for performance when storing large, complex third-party class instances in a reactive state.

snippet.js
javascript
1
2
3
4
5
import { reactive, markRaw } from 'vue';
const state = reactive({
mapInstance: markRaw(new ThirdPartyMapLibrary())
});
vue
Breakdown
1
markRaw(new ThirdPartyMapLibrary())
Prevents Vue from tracking this specific object recursively.