
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@react-hook/media-query
Advanced tools
React hooks that update when media queries change between matched and unmatched states.
npm i @react-hook/media-query
React hooks that update when media queries change between matched and unmatched states.
import {useMediaQuery, useMediaQueries} from '@react-hook/media-query'
// Using a single media query
const Component = () => {
const matches = useMediaQuery('only screen and (min-width: 400px)')
return `Matches? ${matches ? 'Matched!' : 'Nope :(')}`
}
// Using multiple media queries
const Component = () => {
const {matches, matchesAny, matchesAll} = useMediaQueries({
screen: 'screen',
width: '(min-width: 400px)'
})
return (
<div>
Screen matched? {matches.screen ? 'Yes' : 'No'}
Width matched? {matches.width ? 'Yes' : 'No'}
All matched? {matchesAll ? 'Yes' : 'No'}
Any matched? {matchesAny ? 'Yes' : 'No'}
</div>
)
}
A hook that returns true
if the media query matched and false
if not. This hook
will always return false
when rendering on the server.
Argument | Type | Required? | Description |
---|---|---|---|
query | string | Yes | The media query you want to match against e.g. "only screen and (min-width: 12em)" |
boolean
Returns true
if the media query matched. This is always false
when rendering on the server.
A hook that returns a MediaQueryMatches
object which will
tell you if specific media queries matched, all media queries matched, or
any media queries matched. Matches in this hook will always return false
when
rendering on the server.
Argument | Type | Required? | Description |
---|---|---|---|
queryMap | {[Name in keyof T]: string} | Yes | The media queries you want to match against e.g. {screen: "screen", width: "(min-width: 12em)"} |
MediaQueryMatches
export interface MediaQueryMatches<T> {
/**
* Returns a map of query key/didMatch pairs
*/
matches: Matches<T>
/**
* `true` if any of the media queries matched
*/
matchesAny: boolean
/**
* `true` if all of the media queries matched
*/
matchesAll: boolean
}
MIT
FAQs
React hooks that update when media queries change between matched and unmatched states.
We found that @react-hook/media-query demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.