Mark a certain property as unreactive value
See original GitHub issueAs far as I know the current solution for non-reactive class members is:
import User from '@/models/user';
import { Component, Prop, Watch, Vue } from 'vue-property-decorator';
@Component
export default class HelloWorld extends Vue {
private user!: User;
private created(): void {
this.user = new User();
}
}
This is… ok. I guess. Well actually it kind of sucks. I have to trust Vue that it will call created()
. Typescript won’t warn me if I forget to do this.user = new User()
, and it’s quite verbose.
Would it be possible to add a decorator to do this instead?
import User from '@/models/user';
import { Component, Prop, Watch, Vue } from 'vue-property-decorator';
@Component
export default class HelloWorld extends Vue {
@Unreactive
private user: User = new User();
}
(or @Nonreactive
)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to set a component non-reactive data in Vue 2?
I have a categories array, which is loaded once (in created hook) and then it is static all the time. I render these...
Read more >Non-reactive Objects in Vue Composition API
Iterate over the keys of data return value; If the property is already reactive, skip; If the property is a primitive (non-object or...
Read more >The Mark Text element - HTML: HyperText Markup Language
In this first example, a <mark> element is used to mark some text within a quote which is of particular interest to the...
Read more >Focus management and inert | CSS-Tricks
Managing focus requires some skill and care, but is very much worth doing. The inert attribute can go a long way to making...
Read more >Dialog (Modal) | APG | WAI - W3C
Inert content outside an active dialog is typically visually obscured or dimmed so ... A value set for the aria-labelledby property that refers...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just discovered that a big three.js 3d scene has been completely “made reactive” by this, because my scene is a data member of my class. And similarly for another 3rd party deep object. Unfortunately I can’t declare it
private
because I’m using some mixins that also need the same scene. Is there any other option? Maybe avoid “reacting” data members that start with underscore or something?is there a markRaw decorator? how can we use the hook from within a class component?