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

requestIdleCallback not available in Safari #124

Closed
frontsideair opened this issue Jul 17, 2022 · 3 comments · Fixed by #125
Closed

requestIdleCallback not available in Safari #124

frontsideair opened this issue Jul 17, 2022 · 3 comments · Fixed by #125

Comments

@frontsideair
Copy link
Contributor

Have you experienced this bug with the latest version of the template?

Yes

Steps to Reproduce

  • Start a dev server
  • Navigate to it with Safari

Expected Behavior

It should mount React

Actual Behavior

It doesn't mount React, get an error in console:

ReferenceError: Can't find variable: requestIdleCallback

Unfortunately rIC is not supported by Safari, according to caniuse.com. Either its existence should be checked or it should be polyfilled. (Or it can be removed altogether.) I can provide the PR depending on the decision.

@kentcdodds
Copy link
Member

Ah dang. I had no idea 😬 Safari really is the new IE 🙃

Yeah, a PR would be welcome. Let's just do this:

const rIC = requestIdleCallback ?? setTimeout
rIC(() => {
  // ... etc.
})

@frontsideair
Copy link
Contributor Author

Yeah, I had to double check to make sure it's not supported. 😂 I can create a PR, but checking the polyfill linked in MDN, it seems like we should add a timeout of 1 milliseconds (see relaxation). The whole polyfill is not needed as we don't use the args. What do you think?

@kentcdodds
Copy link
Member

Sounds good 👍

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

Successfully merging a pull request may close this issue.

2 participants