Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
make class static property observable in mobx-6

here's my code:

export default class ViewStore {
    templateName = '';
    static views = [];
    constructor(mainStore: MainStore) {
        makeObservable(this, {
            templateName: observable,
            ViewStore.views: observable,
        });
    }
}

I want to define views as observable. I've tried referring to it by this. views and views but none of them worked either.

in mobX5 it was possible by defining @observable before views when defining it like this:

@observable static views = [];

but I don't know how to achieve this in mobX 6

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Basically the same way as you did with MobX@5, but without decorator api:

import { observable } from "mobx";


export default class ViewStore {
    templateName = '';
    // Call observable as a function
    static views = observable([]);
    constructor(mainStore: MainStore) {
        makeObservable(this, {
            templateName: observable,
            // No need this line
            // ViewStore.views: observable,
        });
    }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!