I bundle the codes with ./node_modules/.bin/webpack -d
. I didn't compile ES6 to ES5 except this class fields proposal
.
It give this error:
Uncaught TypeError: this.fetchTestExecutions is not a function
Here's the codes:
import React from 'react'
import Config from 'Config'
class HomePage extends React.Component {
state = {
executions: this.fetchTestExecutions()
}
fetchTestExecutions = () => {
const host = Config.host
return fetch(`${host}/execution/index`)
.then(response => response.json())
.then(json => {
this.setState({executions: json})
})
}
render() {
return(
<div>
{ this.state.executions.map(x => <div>x.from</div>) }
</div>
)
}
}
export default HomePage
Here's the webpack.config.js:
var webpack = require('webpack')
module.exports = {
entry: './src/App.jsx',
output: {
filename: './../public/bundle.js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
query: {
plugins: ['transform-class-properties'],
presets: ['react'],
}
}
]
},
externals: {
'Config': JSON.stringify({host: "http://127.0.0.1:3000"})
}
}
What's wrong?
Thanks for your time!