Not working with mobx simple app
See original GitHub issueI 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:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just mentioning here that I got this as well when I tried to import
observable
frommobx-react
. When I changed it to justmobx
it worked. i.e.:import { observable } from 'mobx';
Guys, I’ve created another repo.
As @Tiwaz89 said, the imports are wrong.
@observable
and@computed
belongs tomobx
package (it’s obvious).@observer
belongs to themobx-react
package.MobX documentation for
@observable
,@computed
and@observer
are very clear and brings an example right in the top of the article.