question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not working with mobx simple app

See original GitHub issue

I am working on a project using mobx + react. And I need to use decorators. But I am getting an Uncaught TypeError: decorator is not a function in the Chrome console after Webpack bundle. Webpack shows no errors.

My webpack loader.

{
  test: /\.js$/,
  exclude: /(node_modules|bower_components)/,
  loader: 'babel', // 'babel-loader' is also a legal name to reference
  cacheDirectory: true,
  query: {
    plugins: [
      "transform-decorators-legacy",
    ],
    presets: ['react', 'es2015', 'stage-1']
  }
}

My dependencies:

"devDependencies": {
  "babel-cli": "^6.10.1",
  "babel-core": "^6.10.4",
  "babel-loader": "^6.2.4",
  "babel-plugin-transform-decorators-legacy": "^1.3.4",
  "babel-preset-es2015": "^6.9.0",
  "babel-preset-react": "^6.11.1",
  "babel-preset-stage-1": "^6.5.0",
  "mobx": "^2.3.6",
  "mobx-react": "^3.5.0",
  "react": "^15.2.1",
  "react-dom": "^15.2.1",
  "webpack": "^1.13.1"
}

Some further investingation points to this plugin. The errors pops out in the _applyDecoratedDescriptor method.

Am I missing something?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

40reactions
deangibson89commented, Dec 5, 2016

Just mentioning here that I got this as well when I tried to import observable from mobx-react. When I changed it to just mobx it worked. i.e.: import { observable } from 'mobx';

26reactions
andreyluizcommented, Dec 31, 2016

Guys, I’ve created another repo.

As @Tiwaz89 said, the imports are wrong.

@observable and @computed belongs to mobx package (it’s obvious). @observer belongs to the mobx-react package.

MobX documentation for @observable, @computed and @observer are very clear and brings an example right in the top of the article.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ten minute introduction to MobX and React
MobX. Ten minute introduction to MobX and React. MobX is a simple, scalable and battle tested state management solution. This tutorial will teach...
Read more >
React Mobx can't display observable contents, very simple app
the problem seems to be the version, I downgraded my Mobx to 5.10.1 and my mobx-react-lite to 1.4.1 then Boom everything's fine now....
Read more >
Using Mobx As A State Manager In React Native Applications
In this tutorial, we are going to learn how to use the MobX library for state management; understand the core concepts, some use...
Read more >
Introduction to MobX with React - LogRocket Blog
Learn how to use MobX, a simple, scalable state management tool, ... cuts through the noise to proactively resolve issues in your app...
Read more >
State management in React with MobX - OpenReplay Blog
You can separate the stores so all application states will be in a single store like Redux. One of the top issues about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found