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 "./components/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?
You did not export the ReleaseState
class in release-state.js
. Try modifying your code to:
export default class ReleaseState {
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With