Simple Window Resize React
I'm attempting to capture the window height and pass it to child components in react. I'm referring to this guide from the manual: https://facebook.github.io/react/tips/dom-event-l
Solution 1:
Your handleResize function's body will get the window context. You can bind it to your component class in constructor :
constructor(){
...
this.handleResize = this.handleResize.bind(this);
...
}
Solution 2:
You can't access the Component's attributes or functions from a different Context (in this case the Callback). You need to bind your Callback function if you need to use your component as the Context, the function should look like this:
jsonp(url, {}, function (err, data) {
// your codethis.setState({ images });
}.bind(this));
Same goes for your handlesize
function.
Post a Comment for "Simple Window Resize React"