Skip to content
Merged
Prev Previous commit
Next Next commit
Add pollyfills to the error-overlay iframe script
  • Loading branch information
tharakawj committed Oct 3, 2017
commit a52592f4263a2eafaa614582b24fab591c757cdf
2 changes: 2 additions & 0 deletions packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"babel-loader": "^7.1.2",
"babel-runtime": "6.26.0",
"html-entities": "1.2.1",
"object-assign": "^4.1.1",
"promise": "^8.0.1",
"react": "^15 || ^16",
"react-dom": "^15 || ^16",
"settle-promise": "1.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/react-error-overlay/src/iframeScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import './utils/pollyfills.js';
import React from 'react';
import ReactDOM from 'react-dom';
import CompileErrorContainer from './containers/CompileErrorContainer';
Expand Down
21 changes: 21 additions & 0 deletions packages/react-error-overlay/src/utils/pollyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';

if (typeof Promise === 'undefined') {
// Rejection tracking prevents a common issue where React gets into an
// inconsistent state due to an error, but it gets swallowed by a Promise,
// and the user has no idea what causes React's erratic future behavior.
require('promise/lib/rejection-tracking').enable();
window.Promise = require('promise/lib/es6-extensions.js');
}

// Object.assign() is commonly used with React.
// It will use the native implementation if it's present and isn't buggy.
Object.assign = require('object-assign');