diff --git a/tips/11-dom-event-listeners.md b/tips/11-dom-event-listeners.md index 305a0a4b..46e577ff 100644 --- a/tips/11-dom-event-listeners.md +++ b/tips/11-dom-event-listeners.md @@ -9,7 +9,7 @@ next: initial-ajax.html > Note: > -> This entry shows how to attach DOM events not provided by React ([check here for more info](/react/docs/tips/events.html)). This is good for integrations with other libraries such as jQuery. +> This entry shows how to attach DOM events not provided by React ([check here for more info](/react/docs/events.html)). This is good for integrations with other libraries such as jQuery. Try to resize the window: @@ -20,15 +20,19 @@ var Box = React.createClass({ getInitialState: function() { return {windowWidth: window.innerWidth}; }, + handleResize: function(e) { this.setState({windowWidth: window.innerWidth}); }, + componentDidMount: function() { window.addEventListener('resize', this.handleResize); }, + componentWillUnmount: function() { window.removeEventListener('resize', this.handleResize); }, + render: function() { return