Skip to content

Instantly share code, notes, and snippets.

View Khachatour's full-sized avatar
Crafting

Khachatur Khachatour

Crafting
View GitHub Profile
@Khachatour
Khachatour / the-bind-problem.jsx
Created June 3, 2017 08:23 — 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));
{
"title": 'My title',
"notes": [
{
"title":'My note title',
"note": 'my lovely note'
}
]
}
mock content
mock content
mock content
mock content
mock content
mock content
mock content
mock content