I'm using ES6 to define methods in a React component.
class RootContainer extends Component {
componentWillMount() {
window.addEventListener('resize', this.handleWindowSizeChange)
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleWindowSizeChange)
}
handleWindowSizeChange = () => {
this.props.update_width(window.innerWidth)
}
[...]
I'm mostly using the ES6 syntax so that I don't have to bind my method in my constructor. This code works just fine, unfortunately, whenever I try to build my app, I get a nice handleWindowSizeChange is not defined - no undef
How am I supposed to define it ?