This is what I mean:
import React from "react";
class App extends React.Component {
constructor(props) {
super(props);
this.state = { data: [] }
}
componentWillMount() {
this.setState({ data: import "./data/myData.json" });
}
// etc...
}
This does not work. But this does:
import React from "react";
class App extends React.Component {
constructor(props) {
super(props);
this.state = { data: [] }
}
componentWillMount() {
this.setState({ data: require("./data/myData.json") });
}
// etc...
}
The only reason I want to get it working with ES6 syntax is to be consistent. Is this achievable?