Skip to content

Instantly share code, notes, and snippets.

View sinxwal's full-sized avatar
🕸️
(•___•)

Sergei Tskhovrebov sinxwal

🕸️
(•___•)
  • Frankfurt, Germany
View GitHub Profile
@sinxwal
sinxwal / the-bind-problem.jsx
Created September 27, 2017 08:17 — forked from Restuta/the-bind-problem.jsx
React, removeEventListener and bind(this) gotcha
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));