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

16.8.0-alpha.0 (and 16.7) IE11 Suspense doesn't stop rendering fallback after Lazy resolves #14583

Closed
Kazimirkas opened this issue Jan 13, 2019 · 17 comments · Fixed by #14592
Closed

Comments

@Kazimirkas
Copy link

Kazimirkas commented Jan 13, 2019

Do you want to request a feature or report a bug?

report a bug

What is the current behavior?

When using Suspense, I see React.Suspense fallback layout instead of loaded component in IE 11 (IE network panel shows, that bundle was loaded)

I can not reproduce this bug in 16.7.0-alpha.2! there is everything ok.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

const UserCabinet = React.lazy(() => import('PublicUser/components/UserCabinet/UserCabinet'));

function WaitingComponent(Component) {
  return props => (
    <React.Suspense fallback={<div>Loading...</div>}>
      <Component {...props} />
    </React.Suspense>
  );
}

class PublicRoutes extends React.Component<{}> {
  render() {
    return (
      <Switch>
        <PublicPage path="/login" component={AuthPage} />
        <PublicPage path="/signUp" component={SignUpPage} />
        <PrivatePage path="/cabinet" component={WaitingComponent(UserCabinet)} />
        <Redirect to="/login" />
      </Switch>
    );
  }
}

What is the expected behavior?
see the rendered component

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Tested on IE11 on windows 7
It reproduces only in 16.8.0-alpha.0
I can not reproduce this bug in 16.7.0-alpha.2, there is everything ok.
In Chrome is everything ok in all versions.

@Kazimirkas
Copy link
Author

the problem was with requirements for additional polyfills in newer version

@gaearon
Copy link
Collaborator

gaearon commented Jan 14, 2019

Hmm which ones? I wouldn't expect that.

@gaearon
Copy link
Collaborator

gaearon commented Jan 14, 2019

Could be the same as #14570. A reproducing example would be very helpful; that's unexpected.

@threepointone
Copy link
Contributor

@Kazimirkas can you try running this codesandbox and see if it runs on IE11? https://codesandbox.io/s/oo3rn9z8wq if not on codesandbox, try to run it locally. thanks!

@aweary
Copy link
Contributor

aweary commented Jan 14, 2019

I tested this in IE11 with a small example using Suspense as well as @threepointone's example and both appear to work correctly.

@Kazimirkas are you possibly using a WeakSet polyfill? Which Promise polyfill are you using?

@Kazimirkas
Copy link
Author

Kazimirkas commented Jan 14, 2019

@gaearon @threepointone. IE11 didn't throw any exceptions. So, that I don't know yet, what exactly polyfill do I need. I solved my problem with polyfill.io. I can use only the core-js promise polyfill for 16.7.0-alpha.2 and it works.
Im using browserstack for IE11. Unfortunately WeakSet polyfill (as @aweary recommended) dint't helped.

This is the case without bug React 16.7.0-alpha.2
https://codesandbox.io/s/vyrn9yqy87

This is the buggy case React 16.7
https://codesandbox.io/s/n3kz6l7q9j

I will try to find the exact polyfill, but I don't have any ideas yet :).
I runned those examples locally, because they wan't work form sandbox, IE requires more stuff

@Kazimirkas
Copy link
Author

screen shot 2019-01-14 at 9 52 58 pm

@Kazimirkas Kazimirkas changed the title 16.8.0-alpha.0 IE11 Suspense doesn't stop rendering fallback after Lazy resolves 16.8.0-alpha.0 and 16.7 IE11 Suspense doesn't stop rendering fallback after Lazy resolves Jan 14, 2019
@Kazimirkas Kazimirkas changed the title 16.8.0-alpha.0 and 16.7 IE11 Suspense doesn't stop rendering fallback after Lazy resolves 16.8.0-alpha.0 (and 16.7) IE11 Suspense doesn't stop rendering fallback after Lazy resolves Jan 14, 2019
@Kazimirkas
Copy link
Author

Kazimirkas commented Jan 14, 2019

@gaearon @threepointone I found matching polyfills after reading 4a10721 and @aweary question about Weakmap
You need to import not only the Promise, you need to add Set

import "core-js/es6/promise";
import "core-js/es6/set";

This is the working version for React 16.7

https://codesandbox.io/s/6mx088vvk

@aweary
Copy link
Contributor

aweary commented Jan 14, 2019

@Kazimirkas to clarify, I wasn’t suggesting that you use a WeakSet polyfill, I was just asking if you were already using one. Just in case it might have been a bad implementation that was causing problems.

If you only include the Set polyfill does it work as expected?

@Kazimirkas
Copy link
Author

You're right, I just removed WeakSet and it also works.

@Kazimirkas
Copy link
Author

@aweary Thank you for the hint with Sets!

@gaearon
Copy link
Collaborator

gaearon commented Jan 14, 2019

Ah okay, in that case it's expected. React 16 requires both Map and Set.

This is in the documentation:
https://reactjs.org/docs/javascript-environment-requirements.html

And in React 16 release notes:
https://reactjs.org/blog/2017/09/26/react-v16.0.html#javascript-environment-requirements

That it worked before without Set is a happy accident.

Hope it helps!

@aweary
Copy link
Contributor

aweary commented Jan 14, 2019

It worked because IE11 has native Set implementation, but it isn't compliant. The issue is likely 4a10721#diff-1996f2b11f9c68c0a81652e32be88ddbR217, where we use the new Set([iterable]) API which IE11 doesn't support.

@gaearon maybe we should warn for this?

@Kazimirkas
Copy link
Author

Kazimirkas commented Jan 14, 2019

@aweary And how about the Promise ? :) reactjs/react.dev#1552

@gaearon
Copy link
Collaborator

gaearon commented Jan 15, 2019

Ahh. @aweary Can you send a PR that just replaces it with an add() right after creation? I think we didn't want to rely on this.

@gaearon gaearon reopened this Jan 15, 2019
@gaearon
Copy link
Collaborator

gaearon commented Jan 15, 2019

@Kazimirkas If you use lazy you need Promise by definition — it depends on you using dynamic import which gives you a Promise.

aweary pushed a commit to aweary/react that referenced this issue Jan 15, 2019
Fixes facebook#14583

Using `new Set([iterable])` does not work with IE11's non-compliant Set
implementation. By avoiding this pattern we don't need to require a Set
polyfill for IE11
gaearon pushed a commit that referenced this issue Jan 15, 2019
Fixes #14583

Using `new Set([iterable])` does not work with IE11's non-compliant Set
implementation. By avoiding this pattern we don't need to require a Set
polyfill for IE11
jetoneza pushed a commit to jetoneza/react that referenced this issue Jan 23, 2019
Fixes facebook#14583

Using `new Set([iterable])` does not work with IE11's non-compliant Set
implementation. By avoiding this pattern we don't need to require a Set
polyfill for IE11
n8schloss pushed a commit to n8schloss/react that referenced this issue Jan 31, 2019
Fixes facebook#14583

Using `new Set([iterable])` does not work with IE11's non-compliant Set
implementation. By avoiding this pattern we don't need to require a Set
polyfill for IE11
@nikeee
Copy link
Contributor

nikeee commented May 17, 2019

For me, adding the polyfills for Promise, Set and Map did not suffice. Instead, this is what worked for me in the index.js:

import "react-app-polyfill/ie11";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants