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

@rehooks/component-size

Package Overview
Dependencies
Maintainers
6
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rehooks/component-size - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

23

index.js
'use strict'
let { useCallback, useState, useLayoutEffect } = require('react')
var React = require('react')
var useState = React.useState
var useCallback = React.useCallback
var useLayoutEffect = React.useLayoutEffect

@@ -19,7 +22,7 @@ function getSize(el) {

function useComponentSize(ref) {
let [ComponentSize, setComponentSize] = useState(
getSize(ref ? ref.current : {})
)
var _useState = useState(getSize(ref ? ref.current : {}))
var ComponentSize = _useState[0]
var setComponentSize = _useState[1]
const handleResize = useCallback(
var handleResize = useCallback(
function handleResize() {

@@ -34,3 +37,3 @@ if (ref.current) {

useLayoutEffect(
() => {
function() {
if (!ref.current) {

@@ -43,6 +46,8 @@ return

if (typeof ResizeObserver === 'function') {
let resizeObserver = new ResizeObserver(() => handleResize())
var resizeObserver = new ResizeObserver(function() {
handleResize()
})
resizeObserver.observe(ref.current)
return () => {
return function() {
resizeObserver.disconnect(ref.current)

@@ -54,3 +59,3 @@ resizeObserver = null

return () => {
return function() {
window.removeEventListener('resize', handleResize)

@@ -57,0 +62,0 @@ }

{
"name": "@rehooks/component-size",
"version": "1.0.2",
"version": "1.0.3",
"description": "React hook for component-size",
"main": "index.js",
"repository": "https://github.com/rehooks/component-size",
"author": "Fouad Matin <open@m@fouad.org>",
"author": "Fouad Matin <m@fouad.org>",
"license": "MIT",

@@ -25,13 +25,13 @@ "publishConfig": {

"peerDependencies": {
"react": "^16.7.0-alpha.0"
"react": ">=16.8.0"
},
"devDependencies": {
"@types/react": "^16.4.18",
"ava": "^0.25.0",
"browser-env": "^3.2.5",
"parcel": "^1.10.3",
"raf": "^3.4.0",
"react": "^16.7.0-alpha.0",
"react-dom": "^16.7.0-alpha.0",
"react-test-renderer": "^16.7.0-alpha.0"
"@types/react": "16.4.18",
"ava": "0.25.0",
"browser-env": "3.2.5",
"parcel": "^1.12.3",
"raf": "3.4.0",
"react": "16.8.1",
"react-dom": "16.8.1",
"react-test-renderer": "16.8.1"
},

@@ -38,0 +38,0 @@ "ava": {

@@ -42,3 +42,3 @@ # `@rehooks/component-size`

> [Can i use ResizeObserver?](https://caniuse.com/#feat=ResizeObserver)
> [Can i use ResizeObserver?](https://caniuse.com/#feat=resizeobserver)

@@ -88,2 +88,2 @@ ### Polyfill

}
```
```
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