Cannot read property map of undefined
randohinn opened this issue · comments
Rando Hinn commented
The current Vibrant release gives an error like this.
Vibrant.js:651 Uncaught (in promise) TypeError: Cannot read property 'map' of undefined
at new Vibrant (Vibrant.js:651)
at workList.js:89
at Array.forEach (<anonymous>)
at workList.js:86
at <anonymous>
Where the code calling Vibrant is
const image = new Image(200, 200);
image.src = item.fields.image.fields.file.url;
const vibrant = new Vibrant(image);
const swatches = vibrant.swatches();
alert(swatches[0].getHex());
poshest commented
I get the same error in Chrome Version 59.0.3071.115 (Official Build) (32-bit) on Win7. And since Chrome just updated itself when I opened Help>About, it also doesn't work in Version 60.0.3112.90 (Official Build) (32-bit)
Gilberto Lenzi commented
I have the same problem – bump.
Jari commented
You need to wait for the image to load before passing it onto Vibrant...
See the example code at https://jariz.github.io/vibrant.js/