mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +00:00
bind this in onreadystatechange call
Summary: I ran into this problem that `this` is undefined in `onreadystatechange` function calls while using this github api library: https://github.com/michael/github/blob/master/github.js#L72 It seems that in the browser, the `onreadystatechange` function expects `this` to be bound. This example on the xhr spec website can be seen using `this` similarly: https://xhr.spec.whatwg.org/#the-getresponseheader()-method Closes https://github.com/facebook/react-native/pull/5373 Reviewed By: svcscm Differential Revision: D2838940 Pulled By: nicklockwood fb-gh-sync-id: e42184887c7abb0af9c4358a5f33b8c97155624c
This commit is contained in:
parent
474b5e9b80
commit
b8ff6212f8
@ -247,7 +247,7 @@ class XMLHttpRequestBase {
|
||||
if (onreadystatechange) {
|
||||
// We should send an event to handler, but since we don't process that
|
||||
// event anywhere, let's leave it empty
|
||||
onreadystatechange(null);
|
||||
onreadystatechange.call(this, null);
|
||||
}
|
||||
if (newState === this.DONE && !this._aborted) {
|
||||
this._sendLoad();
|
||||
|
Loading…
x
Reference in New Issue
Block a user