feat(useMediaQuery): enhance hook with debounce, fallback and onChange#95
Merged
aprendendofelipe merged 1 commit intomainfrom Jan 13, 2026
Merged
feat(useMediaQuery): enhance hook with debounce, fallback and onChange#95aprendendofelipe merged 1 commit intomainfrom
aprendendofelipe merged 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@barso/forms
@barso/helpers
@barso/hooks
@barso/infra
@barso/ui
commit: |
There was a problem hiding this comment.
Pull request overview
This PR enhances the useMediaQuery hook with debouncing capabilities, SSR fallback support, and an onChange callback. The implementation leverages React 18's useSyncExternalStore for improved consistency and SSR safety.
Changes:
- Refactored hook to use
useSyncExternalStorefor better React 18 compatibility - Added debounce support to prevent excessive re-renders during rapid media query changes
- Added fallback option for SSR and hydration scenarios (supports both boolean values and functions)
- Added onChange callback for side effects when media query state changes
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
packages/hooks/src/useMediaQuery/useMediaQuery.js |
Complete rewrite implementing new features using useSyncExternalStore, debounce logic, fallback handling, and onChange callback |
packages/hooks/src/useMediaQuery/useMediaQuery.test.js |
Added tests for debounce functionality, onChange callback, and SSR fallback scenarios |
packages/hooks/src/useMediaQuery/README.md |
New comprehensive documentation with usage examples, API reference, and Next.js integration guide |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…d onChange callback
adef03d to
371d71c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
useMediaQuery