Skip to content

All dimensions returned as 0 #29

@dfsa-bot

Description

@dfsa-bot

Hey,
I'm kind of stuck with all dimensions being 0 on first Component render. Hot-reloading somehow magically sets the values to correct ones but that obviously won't do.
Nothing fancy here:

const [itemRef, { x }, node] = useDimensions()

useEffect(() => {
  console.log(x)
}, [x])

...
return (
  <Component ref={itemRef}>
    {children}
  </Component>
)
...

Actually the first render gets me all 'undefined' (including node), the second one comes back with 0s and node as actual HTMLElement.

Any ideas what might be the cause of this? The container element is a flex-box wrapper - I thought this might be it but then tried to run useDimensions on that element and same results came back

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions