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

Make useMediaQuery return the correct value on the first render #21682

Merged
merged 3 commits into from
Apr 17, 2020
Merged

Make useMediaQuery return the correct value on the first render #21682

merged 3 commits into from
Apr 17, 2020

Conversation

alshakero
Copy link
Contributor

Hi!

This is a small patch for #21676.

Description

Instead of defaulting to false for useMediaQuery's hook state, I made it default to the actual value and thus returning the right value from the very beginning.

How has this been tested?

I also added a test for this case that doesn't call act, so it doesn't wait for the effects to take place but still expects the right value.

Types of changes

This is a non-breaking change. And doesn't change the hook's API at all. At least not the expected API.

Checklist:

  • My code is unit tested. But not manually tested because I couldn't find any usage of the hook within Gutenberg.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Looks and works great, Thanks for the fix

@youknowriad youknowriad added the [Type] Bug An existing feature does not function as intended label Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants