I have a React project written in ES6. It is compiled using Babel and works quite well. Except for one promise (of many!) that acts up only in IE, for which I already know – has no support for promises. So I immediately thought to add a polyfill to supply promises for IE, but then I was like "Hold up, you're already writing ES6 and isn't that compiled into ES5 anyways?" Who would know better than SO?
So is there any sense in adding a polyfill such as es6-promise to my project? And if there is, how should I use it syntactically? For now I only have the import but I should probably implement it somehow as well?
import Promise from 'es6-promise';
Also here's the promise that causes problems in IE, perhaps I have a syntax error that I haven't noticed myself! 🙂
new SingleObjectResource(DJ_CONST.API.setLanguage)
.put(null, {language_code: theLanguage})
.then(
function() {
window.location.reload();
}
);
Best Answer
I had the same situation & was very frustrated as i had to deploy production app, The problem i had was with Promises from fetchjs. This is what i do to save my life
and then in my main JS file, justed called this
as from here https://github.com/stefanpenner/es6-promise#auto-polyfill
basically, its alternative syntax of
Basically, Under the hood The polyfill() method will patch the global environment (in this case to the Promise name) when called.
Note: i was using gulp with browserify.