Advertisement
Guest User

polyfills.js

a guest
Mar 21st, 2018
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (typeof Promise === 'undefined') {
  2.   // Rejection tracking prevents a common issue where React gets into an
  3.   // inconsistent state due to an error, but it gets swallowed by a Promise,
  4.   // and the user has no idea what causes React's erratic future behavior.
  5.   require('promise/lib/rejection-tracking').enable();
  6.   window.Promise = require('promise/lib/es6-extensions.js');
  7. }
  8.  
  9. // fetch() polyfill for making API calls.
  10. require('whatwg-fetch');
  11.  
  12. // Object.assign() is commonly used with React.
  13. // It will use the native implementation if it's present and isn't buggy.
  14. Object.assign = require('object-assign');
  15.  
  16. // In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet.
  17. // We don't polyfill it in the browser--this is user's responsibility.
  18. if (process.env.NODE_ENV === 'test') {
  19.   require('raf').polyfill(global);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement