我对React和Mobx都很陌生,所以我尝试做一个小应用程序。当我尝试运行它时,出现错误:Uncaught TypeError: _releasesState2.default is not a constructor
。由于我不知道问题出在哪里,我快要绝望了。这是我目前的代码:
我的index.js:
import React from "react";
import ReactDOM from "react-dom";
import Releases from "./components/releases";
class App extends React.Component {
constructor() {
super();
}
render() {
return (
<div>
<Releases />
</div>
)
}
}
ReactDOM.render(<App/>, window.document.getElementById("app"));
releases.js文件:
import React from "react";
import { observer } from "mobx-react";
import ReleaseState from "./releases-state";
@observer
export default class Releases extends React.Component {
constructor() {
super();
this.state = new ReleaseState();
}
render() {
return (
<div>
// content here
</div>
)
}
}
以及 releases-state.js 文件:
import { observable } from "mobx"
class ReleaseState {
@observable releases = [];
constructor() {
let data = [] // some array with data
}
}
const releaseState = new ReleaseState();
有人可以告诉我这里出了什么问题吗?