Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decorate incompatible with Babel 7's class properties #1471

Closed
2 tasks done
rgrochowicz opened this issue Mar 30, 2018 · 1 comment
Closed
2 tasks done

decorate incompatible with Babel 7's class properties #1471

rgrochowicz opened this issue Mar 30, 2018 · 1 comment

Comments

@rgrochowicz
Copy link

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
    });
  }
}

Versions:
mobx: 4.1.1
babel: 7.0.0-beta.42
react-scripts: 2.0.0-next.b2fd8db8
Chrome: 65.0.3325.181

  • Provide a minimal sample reproduction.
  • Did you check this issue wasn't filed before?
@mweststrate
Copy link
Member

You will have to use this plugin in loose mode. Without that, properties become simply undecoratable until the new decorators proposal is implemented as well. Which is currently WIP and tracked in #1352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants