Skip to content

[useMediaQuery] Doesn't fire after state change #36165

@pavsidhu

Description

@pavsidhu

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/charming-microservice-imyon7?file=/src/App.tsx

Steps:

  1. Increase and decrease the window width so you can see the media query updates correctly in the console
  2. Resize the screen to larger than 600px width and press the button, this will fire the if statement and update the state of isActive
  3. Now try resizing. the window width above and below 600px

Current behavior 😯

The component only rerenders when resizing the window when the media query does not match

Expected behavior 🤔

I expect the component to also rerender when the media query matches

Context 🔦

No response

Your environment 🌎

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions