-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[v2] IE11 throws Objects are not valid as a React child #7003
Comments
This does not occur in the starter project and another project which I'm working on. |
No it's not gatsbyjs.org specific because I first noticed it when migrating reactjs.org (preview link) to v2. Here is the repo for that if you need it. My best guess would be that polyfills aren't loaded correctly, like the Here is an issue that might help facebook/react#8379 |
I worked around this by adding the babel polyfills as a webpack entry point in exports.onCreateWebpackConfig = ({
stage,
getConfig,
actions: { replaceWebpackConfig }
}) => {
switch (stage) {
case 'build-javascript':
// We want to include the babel polyfills before any application code,
// so we're inserting it as an additional entry point. Gatsby does not allow
// this in "setWebpackConfig", so we have to use "replaceWebpackConfig"
const config = getConfig();
const app =
typeof config.entry.app === 'string'
? [config.entry.app]
: config.entry.app;
config.entry.app = ['@babel/polyfill', ...app];
replaceWebpackConfig(config);
}
}; |
Hmm could it be |
From reading facebook/react#8379 (comment) one possibility is that the polyfill is loading after React which could be happening since we're relying on Babel 7's polyfilling which adds polyfill imports as they're needed — which wouldn't actually be working since we don't run React through Babel. Ah yeah, confirmation babel/babel#7335 (comment) So we need to manually add the necessary polyfills to ensure they're run first. |
One way to do this is to a) add the polyfills directly at the top of Thoughts? Anyone want to tackle this? |
How would we be able to remove them in the webpack config though 🤔 I suppose you mean like this // production-app.js
import '@babel/polyfill'
// or just the necessary polyfills
import 'core-js/es6/set'
import 'core-js/es6/map' Then AFAIK there is no way to remove them, I could be wrong though Huh strange, always though I could take this on, but unfortunately I won't have time until the weekend-ish. So if anyone else wanna grab this feel free to do so! |
We'd conditionally add https://webpack.js.org/plugins/ignore-plugin/ |
Oh cool, didn't know you could do that! |
It's a neat trick :-) |
If the babel settings for That's what the docs suggest, but I haven't tried it. |
Weird, I can no longer reproduce this in the production build, everything seems to be working now 🤷♂️ Still get errors in development though but I think this is intended right? // .babel-preset.js
const browserConfig = {
useBuiltIns: false,
targets: {
browsers: PRODUCTION
? [`last 4 versions`, `safari >= 7`, "ie >= 9"]
: [`last 2 versions`, `not ie <= 11`, `not android 4.4.3`],
},
} |
Huh that is weird! That bit of code is for compiling the Gatsby owned code. For compiling your code, this is where babel is setup
|
Oh I see! Seems like I can't really figure this one out to be honest... it should technically work if I add this right? // my-gatsby-site/.cache/app.js
import 'core-js/es6/map'
import 'core-js/es6/set'
... If I add a |
I'm seeing this issue too after recently upgrading to v2. Here's some relevant snippets that might help y'all: package.json"dependencies": {
"axios": "0.18.0",
"babel-runtime": "6.26.0",
"intersection-observer": "0.5.0",
"prop-types": "15.6.2",
"react": "16.4.2",
"react-dom": "16.4.2",
"react-dropdown": "1.5.0",
"react-helmet": "5.2.0",
"react-tabs": "2.2.2"
},
"devDependencies": {
"aws-sdk": "2.283.1",
"babel-core": "6.26.3",
"babel-eslint": "8.2.6",
"babel-jest": "23.4.2",
"babel-loader": "7.1.5",
"babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"babel-preset-stage-0": "6.24.1",
"enzyme": "3.3.0",
"enzyme-adapter-react-16": "1.1.1",
"eslint": "4.18.1",
"eslint-config-payscale": "1.0.3",
"eslint-plugin-react": "7.10.0",
"eslint-teamcity": "1.4.0",
"gatsby": "2.0.0-beta.93",
"gatsby-module-loader": "2.0.0-alpha.3",
"gatsby-plugin-google-tagmanager": "2.0.0-beta.3",
"gatsby-plugin-react-helmet": "2.0.11",
"gatsby-plugin-sass": "2.0.0-beta.6",
"gatsby-source-aem": "1.8.8",
"gatsby-source-filesystem": "2.0.1-beta.10",
"gatsby-source-wordpress": "2.0.93",
"gatsby-transformer-json": "2.1.1-beta.4",
"jest": "23.4.2",
"jest-teamcity-reporter": "0.9.0",
"node-sass": "4.9.2",
"react-test-renderer": "16.4.1"
} gatsby-browser.jsconst getPolyfills = () => {
if (!('IntersectionObserver' in window)) {
require('intersection-observer');
}
};
exports.onClientEntry = () => {
getPolyfills();
}; gatsby-config.jsplugins: [
'gatsby-plugin-sass',
'gatsby-plugin-react-helmet',
'gatsby-transformer-json',
// other plugins that aren't relevant Nothing in gatsby-node.js besides createPages Windows 10, node 8.9.4 |
Gatsby's default .babelrc is configured in a manner that automatically imports Babel polyfills based on usage of corresponding API. Such Babel polyfills are loaded after RHL imports `react` module and before page bundle generated by Gatsby imports `react-dom` module, which causes `react` and `react-dom` referring to different Symbol class object, triggering gatsbyjs/gatsby#7003. Refs carbon-design-system#24.
Gatsby's default `.babelrc` is configured in a manner that automatically imports Babel polyfills based on usage of corresponding API. Such Babel polyfills are loaded after RHL imports `react` module and before page bundle generated by Gatsby imports `react-dom` module, which causes `react` and `react-dom` referring to different `Symbol` class object, triggering gatsbyjs/gatsby#7003. Refs carbon-design-system#24.
I am getting this error on the production build in V1.. upgrading to V2 works in production but not in develop |
I was able to resolve the error on localhost by following @stripeyjumper's 2nd comment #7003 (comment) and adding a bit more.
I tried @stripeyjumper's 1st comment #7003 (comment) but I still see an error in IE11 in production Expected ':' TypeError: Object doesn't support this action I am not sure why this workaround works locally, or how to get it to work on production. |
I've just checked www.gatsbyjs.org on IE11 and it works (built with |
@pieh I am getting the issue only when I try to insert a component that is meant to be functional at runtime. If the page is purely "static" I do not see the issue. I will see if I can reproduce with code that I can share at this stage. |
@pieh I am unable to create a simple reproduction of the issue. Tried the usual suspects but they are not creating the issue. From the issue I thought this was a more general problem. Will need to completely break apart the component where this is going wrong. So will dig into that later. |
@AlmeroSteyn I found that
Didn't work for me as well. You mentioned
Myself and others have had success running locally by following these instructions #7003 (comment) . Have you given it a try? |
@sarahannnicholson I dunno what I did the previous time around and which one of the fixes for IE11 dev mode I tried but yours works. Thank you!!! I now have the same situation as you, works in dev, not in prod. Gonna see this morning if I can narrow it down adding some realtime functionality works and others don't. |
@pieh @DSchau I seem to have pinpointed the offending code. It seems that this happens using a child render prop and then combining a props spread operator with setting another prop from the parameter of the render function. The following code reproduces the issue on my side:
If I import and use this in my
and
This is the exact same scenario that also triggers it in my production application. I have also tried the following scenarios and they all worked fine:
So it really seems that this only happens in a render prop. I hope this helps as it would be really great to get this fixed. Note: The same component works fine without console errors in the production build of |
@AlmeroSteyn Would you be able to apply changes from #9135 to your gatsby (in |
@pieh Oh that fixes it alright! Awesome! If I apply those settings, my production app works with minification and has a clean console. Please merge :-) |
I had the same issues as described above in IE11 on v2, and installing gatsby-plugin-polyfill-io fixed it for me. It now runs fine locally and builds fine too. |
Linked PR was merged and published in |
@pieh Thanks you! Test drove it this morning and all good now. Thanks for jumping on it so quickly. |
Pinging @DSchau. We talked yesterday about this error still being thrown in development builds. It looks it might be caused by |
@thetre97 👋 Working on this now! |
I still have this issue with Gatsby v2.0.76 in IE11 (thrown by Edit: conditionally loading polyfill.io features in export const onClientEntry = () =>
new Promise((resolve, reject) => {
const features = []
const isIE = /MSIE|Trident/.test(navigator.userAgent)
let src = 'https://cdn.polyfill.io/v2/polyfill.min.js?callback=__polyfillCallback'
if (!isIE) {
if (!('Set' in window)) {
features.push('Set')
}
if (!('Map' in window)) {
features.push('Map')
}
if (!('Intl' in window)) {
features.push('Intl.~locale.fr')
features.push('Intl.~locale.en')
features.push('Intl.~locale.es')
}
if (!('fetch' in window)) {
features.push('fetch')
}
if (!('URL' in window && 'URLSearchParams' in window)) {
features.push('URL')
}
if (!features.length) {
resolve()
return
}
src += `&features=${features.join(',')}`
}
window.__polyfillCallback = resolve
const tag = document.createElement('script')
tag.src = src
tag.async = true
tag.onerror = reject
document.head.appendChild(tag)
}) I see The only way I found is: setHeadComponents([<script src="https://cdn.polyfill.io/v2/polyfill.min.js" />]) But it means it will always be loaded: I would like to avoid it in modern browsers! |
@antoinerousseau 's solution - though somewhat 'unconventional' - was so far the only way for me to get an IE11 compatible site running. Hope a better solution will be available soon (or IE go away, whichever happens first). |
Been trying to make |
Description
When visiting sites using v2 in IE11 React throws an error
Steps to reproduce
Visit https://next.gatsbyjs.org in IE11 and check the console
Expected result
No errors
Actual result
React throws this error;
Environment
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/AThe text was updated successfully, but these errors were encountered: