admin管理员组文章数量:1303530
I'm new to React and Mobx so I try to do a small app. When I try to run it i get the error: Uncaught TypeError: _releasesState2.default is not a constructor
. I'm about to bash my head in since I have no clue what the issue is. Here is what I got so far:
my index.js:
import React from "react";
import ReactDOM from "react-dom";
import Releases from "./ponents/releases";
class App extends React.Component {
constructor() {
super();
}
render() {
return (
<div>
<Releases />
</div>
)
}
}
ReactDOM.render(<App/>, window.document.getElementById("app"));
the 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>
)
}
}
and the releases-state.js:
import { observable } from "mobx"
class ReleaseState {
@observable releases = [];
constructor() {
let data = [] // some array with data
}
}
const releaseState = new ReleaseState();
Can someone maybe tell me whats wrong here?
I'm new to React and Mobx so I try to do a small app. When I try to run it i get the error: Uncaught TypeError: _releasesState2.default is not a constructor
. I'm about to bash my head in since I have no clue what the issue is. Here is what I got so far:
my index.js:
import React from "react";
import ReactDOM from "react-dom";
import Releases from "./ponents/releases";
class App extends React.Component {
constructor() {
super();
}
render() {
return (
<div>
<Releases />
</div>
)
}
}
ReactDOM.render(<App/>, window.document.getElementById("app"));
the 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>
)
}
}
and the releases-state.js:
import { observable } from "mobx"
class ReleaseState {
@observable releases = [];
constructor() {
let data = [] // some array with data
}
}
const releaseState = new ReleaseState();
Can someone maybe tell me whats wrong here?
Share asked Sep 12, 2017 at 21:28 ST80ST80 3,90317 gold badges72 silver badges144 bronze badges2 Answers
Reset to default 7You did not export the ReleaseState
class in release-state.js
. Try modifying your code to:
export default class ReleaseState {
...
It looks like you might have forgotten to export ReleaseState
?
export default releaseState;
本文标签: javascriptReactJS default is not a constructorStack Overflow
版权声明:本文标题:javascript - ReactJS .default is not a constructor - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741667985a2391428.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论