-
Notifications
You must be signed in to change notification settings - Fork 526
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
Only add a media query event listener where supported #1387
Conversation
🦋 Changeset detectedLatest commit: bb2911d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
src/ThemeProvider.tsx
Outdated
@@ -108,11 +108,11 @@ function useSystemColorMode() { | |||
} | |||
|
|||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | |||
media?.addEventListener('change', handleChange) | |||
media?.addEventListener?.('change', handleChange) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use .addListener()
when .addEventListener()
is not supported?
Looks good! If you confirmed that this fixes the bug in Safari 13, go ahead and merge it 👍 |
This change fixes an issue in safari 13 where an unhandled error from ThemeProvider would cause blank pages. This approach has limitations:
Closes #1366
Screenshots
Please provide before/after screenshots for any visual changes
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.