Vue · Senior · Question 3 of 75
When should you use markRaw on a value stored in reactive state?
const map = shallowRef(markRaw(new mapboxgl.Map({ container: "map" })));- ✓Correct answer: For third-party instances (maps, editors, charts) that must not be wrapped in Proxies
- 2To make the value read-only
- 3To save it to
localStorage
Explanation
Proxying complex class instances costs performance and can break libraries that compare identities or use private fields. markRaw tells Vue never to convert the object.