Skip to content

Issue while updating view Model using setter method #308

@Lingareddyvinitha

Description

@Lingareddyvinitha

Example Code

// STORE
class Todo {
  @observable title = "Test";

  @action.bound
  setTitle(value: string) {
    this.title = value;
  }
}

// CREATE VIEW MODEL
const model = new Todo();
const viewModel = createViewModel(model);

viewModel.setTitle("Updated Test") 
console.log(viewModel.title) // Updated Test
console.log(model.title) // Updated Test

Here when we console the original model we expected title value as "Test" only but actual output is "Updated Test"

package versions:
"mobx": "5.15.0",
"mobx-react": "6.1.4",
"mobx-utils": "5.6.2",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions