I do the following:

MyClass:{ val1: (...) val2: (...) get val1: ƒ () set val1: ƒ (x) get val2: ƒ () set val2: ƒ (x) } @observable x = []; const a = new MyClass(); @action add = () => this.x.push(a); 

When writing a new value in val1 or val2, the rerender in the component does not work, since mobx does not track this case. I can’t figure out how to make mobx follow them and redraw the component with new values. Tell me pliz.

  • Make observable fields in MyClass - Dmitry Kozlov
  • Are there options without modifying the class? - Earthling Magnificent
  • If you cannot change the class, you can make an observable wrapper over MyClass, in which the observable will be a variable containing the MyClass object and action and calculate repeating the getters and setters of MyClass - Dmitry Kozlov
  • @DmitryKozlov format your comment as an answer - Alexandr Tovmach

0