-
Notifications
You must be signed in to change notification settings - Fork 185
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(useAutoDetectAppearance): rm window from useState #6243
fix(useAutoDetectAppearance): rm window from useState #6243
Conversation
size-limit report 📦
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7c623f7:
|
e2e tests |
👀 Docs deployed
Commit 7c623f7 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6243 +/- ##
=======================================
Coverage 81.14% 81.14%
=======================================
Files 324 324
Lines 10091 10090 -1
Branches 3386 3386
=======================================
Hits 8188 8188
+ Misses 1903 1902 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
👍
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.
Упал тест
Описание
Не учёл, что
useState()
вызывается и на сервере. Первое, что может придти в голову – это проверять вuseState
существует лиwindow
, но так сделать не можем, т.к. на клиенте, если пользователь не передалappearance
, то условие отработает удовлетворительно и в первый мы получим автоматическое определениеappearance
, тем самым у нас уже будет разница между клиентом и сервером.В
useState
теперь возвращаем либо пользовательскийappearance
, либо'light'
по умолчанию.В самом эффекте добавил условие для
window
, чтобы убрать неочевидный Non-null Assertion Operator (!
).