Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !4248

Enable loose mode for `class-properties`

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/rgrochowicz/patch-1 into next Apr 03, 2018
  • Overview 14
  • Commits 2
  • Pipelines 0
  • Changes 1

Created by: rgrochowicz

Copying the contents of my MobX issue: After trying out the latest create-react-app and mobx 4's decorate, I found that my classes were no longer observable. At first glance, it looks like it's Babel 7's class property transform.

Here's a codesandbox: https://codesandbox.io/s/623qwprm8k I'd expect the updated value of FooBabel7 to trigger the autorun.

Differences in babel output: Source:

class Foo {
  value = 1;
}

Babel 6:

class Foo {
  constructor() {
    this.value = 1;
  }
}

Babel 7:

class Foo {
  constructor() {
    Object.defineProperty(this, "value", {
      configurable: true,
      enumerable: true,
      writable: true,
      value: 1
    });
  }
}

Enabling loose mode reverts the transform back to the Babel 6 behavior.

Simple before/after: Current behavior: image

With loose: true: image

Original MobX issue: https://github.com/mobxjs/mobx/issues/1471

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/rgrochowicz/patch-1