Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error overlay 'Object.assign' issue in IE #3043

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"babel-code-frame": "6.22.0",
"babel-runtime": "6.26.0",
"html-entities": "1.2.1",
"object-assign": "^4.1.1",
"react": "^15 || ^16",
"react-dom": "^15 || ^16",
"settle-promise": "1.0.0",
Expand Down
11 changes: 5 additions & 6 deletions packages/react-error-overlay/src/components/CodeBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/* @flow */
import React from 'react';
import assign from 'object-assign';
import { redTransparent, yellowTransparent } from '../styles';

const _preStyle = {
Expand All @@ -21,15 +22,13 @@ const _preStyle = {
borderRadius: '0.25rem',
};

const primaryPreStyle = {
..._preStyle,
const primaryPreStyle = assign({}, _preStyle, {
backgroundColor: redTransparent,
};
});

const secondaryPreStyle = {
..._preStyle,
const secondaryPreStyle = assign({}, _preStyle, {
backgroundColor: yellowTransparent,
};
});

const codeStyle = {
fontFamily: 'Consolas, Menlo, monospace',
Expand Down
11 changes: 5 additions & 6 deletions packages/react-error-overlay/src/components/Collapsible.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/* @flow */
import React, { Component } from 'react';
import assign from 'object-assign';
import { black } from '../styles';

const _collapsibleStyle = {
Expand All @@ -25,15 +26,13 @@ const _collapsibleStyle = {
lineHeight: '1.5',
};

const collapsibleCollapsedStyle = {
..._collapsibleStyle,
const collapsibleCollapsedStyle = assign({}, _collapsibleStyle, {
marginBottom: '1.5em',
};
});

const collapsibleExpandedStyle = {
..._collapsibleStyle,
const collapsibleExpandedStyle = assign({}, _collapsibleStyle, {
marginBottom: '0.6em',
};
});

class Collapsible extends Component {
state = {
Expand Down
11 changes: 5 additions & 6 deletions packages/react-error-overlay/src/components/NavigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/* @flow */
import React from 'react';
import assign from 'object-assign';
import { red, redTransparent } from '../styles';

const navigationBarStyle = {
Expand All @@ -28,18 +29,16 @@ const _navButtonStyle = {
cursor: 'pointer',
};

const leftButtonStyle = {
..._navButtonStyle,
const leftButtonStyle = assign({}, _navButtonStyle, {
borderTopRightRadius: '0px',
borderBottomRightRadius: '0px',
marginRight: '1px',
};
});

const rightButtonStyle = {
..._navButtonStyle,
const rightButtonStyle = assign({}, _navButtonStyle, {
borderTopLeftRadius: '0px',
borderBottomLeftRadius: '0px',
};
});

type Callback = () => void;

Expand Down
4 changes: 3 additions & 1 deletion packages/react-error-overlay/src/containers/StackFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ class StackFrame extends Component {
onClick={canOpenInEditor ? this.openInEditor : null}
style={canOpenInEditor ? codeAnchorStyle : null}
>
<CodeBlock {...codeBlockProps} />
{// Use JS instead of JSX spread attributes to avoid Object.assign
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unfortunate. Are you sure this is really an issue? I had an impression that JSX puts extends helper in either case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We have enabled useBuiltIns flag for babel-plugin-transform-react-jsx as well.
https://github.com/facebookincubator/create-react-app/blob/master/packages/babel-preset-react-app/index.js#L27

// in transpiled code which haven't pollyfilled at this point
React.createElement(CodeBlock, codeBlockProps)}
</a>
<button style={toggleStyle} onClick={this.toggleCompiled}>
{'View ' + (compiled ? 'source' : 'compiled')}
Expand Down