Cannot read property ‘type‘ of undefined Occurred while linting **index.jsx:1

今一个react 中使用mobx 老是提示Cannot read property 'type' of undefined Occurred while linting **index.jsx:1

在这里插入图片描述

头疼起初是认为是 @observable的问题,于是修改了整个js

将:

export default class AppState {
	  @observable count = 1
	  @observable name = 'jack'
	  @computed get msg() {
	    return `${this.name} say count is ${this.count}`
	  }
	  @action add() {
	    this.count += 1
	  }
  }

改成了:

const AppState = observable({
  // observable 属性:
  name: 'John',
  count: 42,
  showAge: false,

  // @computed 计算属性:
  get msg() {
    return `${this.name} say count is ${this.count}`;
  },

  // @action 动作:
  add() {
    this.count += 1;
  },
})

然而重新运行只是少了一些错误罢了,问题依然未解决

在这里插入图片描述

最后在 “Cannot read property ‘type’ of undefined” after upgrading to 4.14.0 #9767
找到了一个解决方法

"babel-eslint": "^7.2.3",升级为"babel-eslint": "^8.1.1", 这下终于没提示了

原文地址:https://www.cnblogs.com/dengxiaoning/p/14460940.html