Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-media-hook

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-media-hook - npm Package Compare versions

Comparing version 0.4.9 to 0.5.0

LICENSE

27

index.js
var React = require('react')
function fallbackMathMedia (query) {
function fallbackMatchMedia (query) {
if (typeof matchMedia !== 'function') {

@@ -18,4 +18,11 @@ return null

function useMedia (query) {
var mounted = React.useState(false)
var setMounted = mounted[1]
React.useEffect(function () {
setMounted(true)
}, [setMounted])
var result = React.useState(function () {
return omitMatchMediaResult(fallbackMathMedia(query))
return omitMatchMediaResult(fallbackMatchMedia(query))
})

@@ -30,6 +37,12 @@ var setResult = result[1]

function () {
var matchMediaResult = fallbackMathMedia(query)
var matchMediaResult = fallbackMatchMedia(query)
callback(matchMediaResult)
matchMediaResult.addListener(callback)
return function () { return matchMediaResult.removeListener(callback) }
if (matchMediaResult) {
matchMediaResult.addEventListener('change', callback)
}
return function () {
if (matchMediaResult) {
matchMediaResult.removeEventListener('change', callback)
}
}
},

@@ -39,2 +52,6 @@ [callback, query]

if (!mounted[0]) {
return null
}
return result[0]

@@ -41,0 +58,0 @@ }

4

package.json
{
"name": "react-media-hook",
"version": "0.4.9",
"version": "0.5.0",
"main": "index.js",

@@ -20,3 +20,3 @@ "types": "index.d.ts",

],
"limit": "189 B",
"limit": "230 B",
"path": "./index.js",

@@ -23,0 +23,0 @@ "running": false

# react-media-hook
[![CircleCI](https://circleci.com/gh/lessmess-dev/react-media-hook.svg?style=shield)](https://circleci.com/gh/lessmess-dev/react-media-hook)
[![CircleCI](https://circleci.com/gh/ilyalesik/react-media-hook.svg?style=shield)](https://circleci.com/gh/ilyalesik/react-media-hook)
[![npm version](https://img.shields.io/npm/v/react-media-hook.svg)](https://www.npmjs.com/package/react-media-hook)

@@ -56,8 +56,1 @@ [![npm downloads](https://img.shields.io/npm/dt/react-media-hook.svg)](https://www.npmjs.com/package/react-media-hook)

Returns just *true* or *false*.
## Sponsored
<a href="https://lessmess.agency/?utm_source=react-media-hook">
<img src="https://lessmess.agency/badges/sponsored_by_lessmess.svg"
alt="Sponsored by Lessmess" width="236" height="54">
</a>
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc