How to use class instances in ref() state? #11096
-
Hi there! I'm currently working on a project where at one point, I have an object wrapped in a When I try to access it, I unfortunately get problems as it's not a class instance anymore ; it's been modified as a basic object containing a list of method name - method function pairs. The problem is that I absolutely need to store that class instance somewhere in the ref()'s object. How can this be done? Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
const el = ref<HTMLDivElement>(); el.value.classList.add('foo'); |
Beta Was this translation helpful? Give feedback.
-
Wrap the class instance in |
Beta Was this translation helpful? Give feedback.
Wrap the class instance in
markRaw
(class properties won't be reactive, you may need to workaround it but specific solution may depend on the use case)