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(useMediaQuery): fix state stuck for concurrent mode #866

Merged
merged 1 commit into from
Jul 4, 2022
Merged

Conversation

xobotyi
Copy link
Contributor

@xobotyi xobotyi commented Jul 3, 2022

In concurrent mode along with strict mode - synchronous mql state fetch
leads to state stuck. The only way to fix that behaviour is to switch
back to fully asynchronous code.

Upsides - way simpler code, and reduced amount of it.

Due to changes useScreenOrientation also affected.

Checklist

@xobotyi xobotyi added the 🕯️ bug fix One or more bugs fixed label Jul 3, 2022
@xobotyi xobotyi requested a review from JoeDuncko July 3, 2022 13:10
@xobotyi xobotyi self-assigned this Jul 3, 2022
@codecov
Copy link

codecov bot commented Jul 3, 2022

Codecov Report

Merging #866 (c1d3f90) into master (bb6464b) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #866      +/-   ##
==========================================
- Coverage   99.89%   99.89%   -0.01%     
==========================================
  Files          58       58              
  Lines         991      982       -9     
  Branches      177      173       -4     
==========================================
- Hits          990      981       -9     
  Partials        1        1              
Impacted Files Coverage Δ
src/useMediaQuery/useMediaQuery.ts 100.00% <100.00%> (ø)
src/useScreenOrientation/useScreenOrientation.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9c4c6d...c1d3f90. Read the comment docs.

In concurrent mode along with strict mode - synchronous mql state fetch
leads to state stuck. The only way to fix that behaviour is to switch
back to fully asynchronous code.

Upsides - way simpler code, and reduced amount of it.

Due to changes `useScreenOrientation` also affected.

fix #849

BREAKING CHANGE: `useMediaQuery` and `useScreenOrientation` are
asynchronous now and yields `undefined` at very first render, but
updates to actual value right after.
@xobotyi xobotyi changed the title Fix 849 fix(useMediaQuery): fix state stuck for concurrent mode Jul 3, 2022
@xobotyi xobotyi merged commit 75db2b5 into master Jul 4, 2022
@xobotyi xobotyi deleted the fix-849 branch July 4, 2022 05:57
github-actions bot pushed a commit that referenced this pull request Jul 4, 2022
# [15.0.0](v14.7.1...v15.0.0) (2022-07-04)

### Bug Fixes

* **useMediaQuery:** fix state stuck for concurrent mode ([#866](#866)) ([75db2b5](75db2b5)), closes [#849](#849)

### Features

* implement `useControlledRerenderState` hook ([#865](#865)) ([ea4545b](ea4545b))
* **useToggle:** ignore react events passed to state setter ([#867](#867)) ([085f711](085f711)), closes [#861](#861)

### BREAKING CHANGES

* **useToggle:** `useToggle` now ignores react events passed to its
state setter, so it can be used as event handler directly.
* **useMediaQuery:** `useMediaQuery` and `useScreenOrientation` are
asynchronous now and yields `undefined` at very first render, but
updates to actual value right after.
@xobotyi
Copy link
Contributor Author

xobotyi commented Jul 4, 2022

🎉 This PR is included in version 15.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕯️ bug fix One or more bugs fixed released
Development

Successfully merging this pull request may close these issues.

useScreenOrientation and useMediaQuery don't update when window.screen.orientation.lock("landscape") is called
1 participant