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

fix(useAutoDetectAppearance): rm window from useState #6243

Merged

Conversation

inomdzhon
Copy link
Contributor

@inomdzhon inomdzhon commented Dec 8, 2023


  • Unit-тесты
  • Документация фичи

Описание

Не учёл, что useState() вызывается и на сервере. Первое, что может придти в голову – это проверять в useState существует ли window, но так сделать не можем, т.к. на клиенте, если пользователь не передал appearance, то условие отработает удовлетворительно и в первый мы получим автоматическое определение appearance, тем самым у нас уже будет разница между клиентом и сервером.

В useState теперь возвращаем либо пользовательский appearance, либо 'light' по умолчанию.

В самом эффекте добавил условие для window, чтобы убрать неочевидный Non-null Assertion Operator (!).


@inomdzhon inomdzhon requested a review from a team as a code owner December 8, 2023 16:27
Copy link
Contributor

github-actions bot commented Dec 8, 2023

size-limit report 📦

Path Size
JS 348.14 KB (-0.03% 🔽)
JS (gzip) 106.35 KB (-0.01% 🔽)
JS (brotli) 87.81 KB (+0.05% 🔺)
JS import Div (tree shaking) 1.43 KB (0%)
CSS 258.79 KB (0%)
CSS (gzip) 33.79 KB (0%)
CSS (brotli) 27.43 KB (0%)

Copy link

codesandbox-ci bot commented Dec 8, 2023

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:

Sandbox Source
VKUI TypeScript Configuration

Copy link
Contributor

github-actions bot commented Dec 8, 2023

e2e tests

Playwright Report

Copy link
Contributor

github-actions bot commented Dec 8, 2023

👀 Docs deployed

Commit 7c623f7

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e421dcb) 81.14% compared to head (7c623f7) 81.14%.
Report is 7 commits behind head on master.

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     
Flag Coverage Δ
unittests 81.14% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

BlackySoul
BlackySoul previously approved these changes Dec 11, 2023
mendrew
mendrew previously approved these changes Dec 11, 2023
Copy link
Contributor

@mendrew mendrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@SevereCloud SevereCloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Упал тест

packages/vkui/src/hooks/useAutoDetectAppearance.test.ts Outdated Show resolved Hide resolved
@inomdzhon inomdzhon merged commit bf6169d into master Dec 11, 2023
25 checks passed
@inomdzhon inomdzhon deleted the imirdzhamolov/issue6240/fix-useAutoDetectAppearance-ssr branch December 11, 2023 11:35
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 this pull request may close these issues.

[Bug]: v6.0.0-beta.1 сломан SSR для appearance
4 participants