refactor(hooks): rename useNodeDimensions to useNodeBounds

This commit is contained in:
moklick
2021-12-07 04:38:17 +01:00
parent d9c99a8a6d
commit 427c933389
3 changed files with 13 additions and 7 deletions
@@ -1,11 +1,11 @@
import { useCallback } from 'react';
import shallow from 'zustand/shallow';
import { Rect } from '../types';
import { NodeBounds } from '../types';
import { useStore } from '../store';
function useNodeDimensions(id: string): Rect | null {
const nodeDimensions = useStore(
function useNodeBounds(id: string): NodeBounds | null {
const nodeBounds = useStore(
useCallback(
(s) => {
const nodeItem = s.nodeInternals.get(id);
@@ -16,8 +16,8 @@ function useNodeDimensions(id: string): Rect | null {
return {
...nodeItem.positionAbsolute,
width: nodeItem.width ?? 0,
height: nodeItem.height ?? 0,
width: nodeItem.width ?? null,
height: nodeItem.height ?? null,
};
},
[id]
@@ -25,7 +25,7 @@ function useNodeDimensions(id: string): Rect | null {
shallow
);
return nodeDimensions;
return nodeBounds;
}
export default useNodeDimensions;
export default useNodeBounds;