@rpcbase/client 0.253.0 → 0.255.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.253.0",
3
+ "version": "0.255.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "scripts": {
@@ -1,15 +1,16 @@
1
1
  import {useState, useEffect, useRef, useCallback} from "react"
2
2
  import useMeasure from "react-use/lib/useMeasure"
3
3
  import _throttle from "lodash/throttle"
4
- import { isEqual } from "fast-equals"
4
+ import { deepEqual } from "fast-equals"
5
5
 
6
+ const useMeasureHook = useMeasure.default || useMeasure
6
7
 
7
8
  const DEFAULT_THROTTLE_TIME = 16
8
9
 
9
10
  export const useThrottledMeasure = (throttleDuration = DEFAULT_THROTTLE_TIME) => {
10
11
  const hasInitialMeasure = useRef(false)
11
12
 
12
- const [ref, measuredRect] = useMeasure()
13
+ const [ref, measuredRect] = useMeasureHook()
13
14
  const [rect, setRect] = useState(() => {
14
15
  return {x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0}
15
16
  })
@@ -18,7 +19,7 @@ export const useThrottledMeasure = (throttleDuration = DEFAULT_THROTTLE_TIME) =>
18
19
  _throttle(
19
20
  (newRect) => {
20
21
  setRect((current) => {
21
- return isEqual(current, newRect) ? current : newRect
22
+ return deepEqual(current, newRect) ? current : newRect
22
23
  })
23
24
  },
24
25
  throttleDuration,
@@ -31,7 +32,7 @@ export const useThrottledMeasure = (throttleDuration = DEFAULT_THROTTLE_TIME) =>
31
32
  if (measuredRect.width > 0 && !hasInitialMeasure.current) {
32
33
  hasInitialMeasure.current = true
33
34
  setRect((current) => {
34
- return isEqual(current, measuredRect) ? current : measuredRect
35
+ return deepEqual(current, measuredRect) ? current : measuredRect
35
36
  })
36
37
  return
37
38
  }