this is the main React component:
class App extends Component {
componentDidMount() {
console.log(this)
init()
}
// react render
render() {
return (
<div ref={ref => (this.mount = ref)} />
)
}
}
export default App;
And in anotther file, i have this function which i import in App.js:
var init = () => {
console.log(this)
// Initiates the entire env
// Initiate clock
this.clock = new THREE.Clock()
...
// Add event listener in case window resizes
window.addEventListener('resize', this.onWindowResize, false)
...
}
It is to my understanding that an arrow function does not have its own scope/this so that it gets the this of the enclosing scope. Why does it not work in this example? The first print, in the App component prints right and the next print gets undefined.