@react-hookz/web
Advanced tools
Comparing version 14.2.1 to 14.2.2
@@ -0,1 +1,8 @@ | ||
## [14.2.2](https://github.com/react-hookz/web/compare/v14.2.1...v14.2.2) (2022-05-12) | ||
### Bug Fixes | ||
* `useResizeObserver` now respects element changes within ref object ([#759](https://github.com/react-hookz/web/issues/759)) ([2a4e848](https://github.com/react-hookz/web/commit/2a4e8482c29a8374bcd3eabb2e26c7899bc5a4a2)), closes [#755](https://github.com/react-hookz/web/issues/755) | ||
## [14.2.1](https://github.com/react-hookz/web/compare/v14.2.0...v14.2.1) (2022-05-12) | ||
@@ -2,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { RefObject } from 'react'; | ||
import { MutableRefObject } from 'react'; | ||
/** | ||
@@ -7,2 +7,2 @@ * Uses ResizeObserver to track element dimensions and re-render component when they change. | ||
*/ | ||
export declare function useMeasure<T extends Element>(enabled?: boolean): [DOMRectReadOnly | undefined, RefObject<T>]; | ||
export declare function useMeasure<T extends Element>(enabled?: boolean): [DOMRectReadOnly | undefined, MutableRefObject<T | null>]; |
@@ -60,4 +60,10 @@ "use strict"; | ||
var cb = (0, __1.useSyncedRef)(callback); | ||
var tgt = target && 'current' in target ? target.current : target; | ||
(0, react_1.useEffect)(function () { | ||
if (!ro) | ||
// this secondary target resolve required for case when we receive ref object, which, most | ||
// likely, contains null during render stage, but already populated with element during | ||
// effect stage. | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
var tgt = target && 'current' in target ? target.current : target; | ||
if (!ro || !tgt) | ||
return; | ||
@@ -68,5 +74,2 @@ // as unsubscription in internals of our ResizeObserver abstraction can | ||
var subscribed = true; | ||
var tgt = target && 'current' in target ? target.current : target; | ||
if (!tgt) | ||
return; | ||
var handler = function () { | ||
@@ -90,4 +93,4 @@ var args = []; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [target, ro]); | ||
}, [tgt, ro]); | ||
} | ||
exports.useResizeObserver = useResizeObserver; |
@@ -1,2 +0,2 @@ | ||
import { RefObject } from 'react'; | ||
import { MutableRefObject } from 'react'; | ||
/** | ||
@@ -7,2 +7,2 @@ * Uses ResizeObserver to track element dimensions and re-render component when they change. | ||
*/ | ||
export declare function useMeasure<T extends Element>(enabled?: boolean): [DOMRectReadOnly | undefined, RefObject<T>]; | ||
export declare function useMeasure<T extends Element>(enabled?: boolean): [DOMRectReadOnly | undefined, MutableRefObject<T | null>]; |
import { useRef } from 'react'; | ||
import { useSafeState, useResizeObserver, useRafCallback } from '..'; | ||
import { useRafCallback, useResizeObserver, useSafeState } from '..'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Uses ResizeObserver to track element dimensions and re-render component when they change. |
@@ -57,4 +57,10 @@ import { useEffect } from 'react'; | ||
var cb = useSyncedRef(callback); | ||
var tgt = target && 'current' in target ? target.current : target; | ||
useEffect(function () { | ||
if (!ro) | ||
// this secondary target resolve required for case when we receive ref object, which, most | ||
// likely, contains null during render stage, but already populated with element during | ||
// effect stage. | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
var tgt = target && 'current' in target ? target.current : target; | ||
if (!ro || !tgt) | ||
return; | ||
@@ -65,5 +71,2 @@ // as unsubscription in internals of our ResizeObserver abstraction can | ||
var subscribed = true; | ||
var tgt = target && 'current' in target ? target.current : target; | ||
if (!tgt) | ||
return; | ||
var handler = function () { | ||
@@ -87,3 +90,3 @@ var args = []; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [target, ro]); | ||
}, [tgt, ro]); | ||
} |
@@ -1,2 +0,2 @@ | ||
import { RefObject } from 'react'; | ||
import { MutableRefObject } from 'react'; | ||
/** | ||
@@ -7,2 +7,2 @@ * Uses ResizeObserver to track element dimensions and re-render component when they change. | ||
*/ | ||
export declare function useMeasure<T extends Element>(enabled?: boolean): [DOMRectReadOnly | undefined, RefObject<T>]; | ||
export declare function useMeasure<T extends Element>(enabled?: boolean): [DOMRectReadOnly | undefined, MutableRefObject<T | null>]; |
import { useRef } from 'react'; | ||
import { useSafeState, useResizeObserver, useRafCallback } from '..'; | ||
import { useRafCallback, useResizeObserver, useSafeState } from '..'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Uses ResizeObserver to track element dimensions and re-render component when they change. |
@@ -56,4 +56,10 @@ import { useEffect } from 'react'; | ||
const cb = useSyncedRef(callback); | ||
const tgt = target && 'current' in target ? target.current : target; | ||
useEffect(() => { | ||
if (!ro) | ||
// this secondary target resolve required for case when we receive ref object, which, most | ||
// likely, contains null during render stage, but already populated with element during | ||
// effect stage. | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
const tgt = target && 'current' in target ? target.current : target; | ||
if (!ro || !tgt) | ||
return; | ||
@@ -64,5 +70,2 @@ // as unsubscription in internals of our ResizeObserver abstraction can | ||
let subscribed = true; | ||
const tgt = target && 'current' in target ? target.current : target; | ||
if (!tgt) | ||
return; | ||
const handler = (...args) => { | ||
@@ -82,3 +85,3 @@ // it is reinsurance for the highly asynchronous invocations, almost | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [target, ro]); | ||
}, [tgt, ro]); | ||
} |
{ | ||
"name": "@react-hookz/web", | ||
"version": "14.2.1", | ||
"version": "14.2.2", | ||
"description": "React hooks done right, for browser and SSR.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
435305
8789