fix bug where image load errors would keep loading
Dice reported this, thank you! My mistake here was that `loadImage` _does_ reject when the image fails to load… but it ends up throwing `undefined`, since I forgot to pass the error along from `onerror` to `reject`! So we would cancel stuff, but then store `undefined` as our error in state, which our component interprets as no-error. I tested this by using Firefox DevTools request blocking!
This commit is contained in:
parent
f8e625afd2
commit
700073df8a
1 changed files with 1 additions and 1 deletions
|
@ -212,7 +212,7 @@ function loadImage(url) {
|
||||||
const image = new Image();
|
const image = new Image();
|
||||||
const promise = new Promise((resolve, reject) => {
|
const promise = new Promise((resolve, reject) => {
|
||||||
image.onload = () => resolve();
|
image.onload = () => resolve();
|
||||||
image.onerror = () => reject();
|
image.onerror = (e) => reject(e);
|
||||||
image.src = url;
|
image.src = url;
|
||||||
});
|
});
|
||||||
promise.cancel = () => {
|
promise.cancel = () => {
|
||||||
|
|
Loading…
Reference in a new issue