question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mark a certain property as unreactive value

See original GitHub issue

As 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:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
garyocommented, Jul 21, 2020

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?

0reactions
ghostcommented, Apr 23, 2021

is there a markRaw decorator? how can we use the hook from within a class component?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found