Skip to content

Resubscribe media queries when the target window changes - #103

Open
feritcemkahraman wants to merge 1 commit into
react-restart:masterfrom
feritcemkahraman:fix/media-query-window-change
Open

feritcemkahraman wants to merge 1 commit into
react-restart:masterfrom
feritcemkahraman:fix/media-query-window-change

Conversation

@feritcemkahraman

Copy link
Copy Markdown

Changing useMediaQuery's targetWindow while keeping the same query leaves the old window subscribed and returns its match value. Include the target window in the effect dependencies so the old listener is removed and the new window is observed.

The regression fails before the fix and checks the new initial match, subsequent changes, and listener cleanup. All 89 tests pass (one existing skip), TypeScript, declarations and changed-file formatting pass. ESM/CJS compile and export checks pass using the underlying Babel CLI; the npm build wrappers mishandle quoted arguments on Windows. Real-browser matrix not run.

This branch has not been deployed

No deployments
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.

1 participant