diff --git a/packages/visx-responsive/src/components/ParentSize.tsx b/packages/visx-responsive/src/components/ParentSize.tsx index d0743b635..085c55add 100644 --- a/packages/visx-responsive/src/components/ParentSize.tsx +++ b/packages/visx-responsive/src/components/ParentSize.tsx @@ -31,11 +31,13 @@ type ParentSizeState = { export type ParentSizeProvidedProps = ParentSizeState; +const defaultIgnoreDimensions: ParentSizeProps['ignoreDimensions'] = []; + export default function ParentSize({ className, children, debounceTime = 300, - ignoreDimensions = [], + ignoreDimensions = defaultIgnoreDimensions, parentSizeStyles = { width: '100%', height: '100%' }, enableDebounceLeadingCall = true, ...restProps @@ -43,7 +45,12 @@ export default function ParentSize({ const target = useRef(null); const animationFrameID = useRef(0); - const [state, setState] = useState({ width: 0, height: 0, top: 0, left: 0 }); + const [state, setState] = useState({ + width: 0, + height: 0, + top: 0, + left: 0, + }); const resize = useMemo(() => { const normalized = Array.isArray(ignoreDimensions) ? ignoreDimensions : [ignoreDimensions]; diff --git a/packages/visx-responsive/src/components/ParentSizeModern.tsx b/packages/visx-responsive/src/components/ParentSizeModern.tsx index 9f2d3590f..3d590bcae 100644 --- a/packages/visx-responsive/src/components/ParentSizeModern.tsx +++ b/packages/visx-responsive/src/components/ParentSizeModern.tsx @@ -38,11 +38,13 @@ type ParentSizeState = { export type ParentSizeProvidedProps = ParentSizeState; +const defaultIgnoreDimensions: ParentSizeProps['ignoreDimensions'] = []; + export default function ParentSize({ className, children, debounceTime = 300, - ignoreDimensions = [], + ignoreDimensions = defaultIgnoreDimensions, parentSizeStyles = { width: '100%', height: '100%' }, enableDebounceLeadingCall = true, ...restProps